diff options
author | ThibG <thib@sitedethib.com> | 2019-03-28 15:12:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-28 15:12:33 +0100 |
commit | bb316faffff7a76bc89f7e942233f0e14caf60f5 (patch) | |
tree | 260458c7ff43dd82fc02cc7e5ef0920dd8d2a25b /app/serializers | |
parent | 0418bdd71f59b4d7e9f3498f2990c8b044f310e1 (diff) | |
parent | 050efbc12650feaac3e833c4dd740bf090e3dae1 (diff) |
Merge pull request #970 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/serializers')
25 files changed, 59 insertions, 43 deletions
diff --git a/app/serializers/activitypub/accept_follow_serializer.rb b/app/serializers/activitypub/accept_follow_serializer.rb index 3e23591a5..1c1c6ab73 100644 --- a/app/serializers/activitypub/accept_follow_serializer.rb +++ b/app/serializers/activitypub/accept_follow_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::AcceptFollowSerializer < ActiveModel::Serializer +class ActivityPub::AcceptFollowSerializer < ActivityPub::Serializer attributes :id, :type, :actor has_one :object, serializer: ActivityPub::FollowSerializer diff --git a/app/serializers/activitypub/activity_serializer.rb b/app/serializers/activitypub/activity_serializer.rb index c001e28aa..c06d5c87c 100644 --- a/app/serializers/activitypub/activity_serializer.rb +++ b/app/serializers/activitypub/activity_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::ActivitySerializer < ActiveModel::Serializer +class ActivityPub::ActivitySerializer < ActivityPub::Serializer attributes :id, :type, :actor, :published, :to, :cc has_one :proper, key: :object, serializer: ActivityPub::NoteSerializer, if: :serialize_object? diff --git a/app/serializers/activitypub/actor_serializer.rb b/app/serializers/activitypub/actor_serializer.rb index 6746c1782..4b982b955 100644 --- a/app/serializers/activitypub/actor_serializer.rb +++ b/app/serializers/activitypub/actor_serializer.rb @@ -1,8 +1,13 @@ # frozen_string_literal: true -class ActivityPub::ActorSerializer < ActiveModel::Serializer +class ActivityPub::ActorSerializer < ActivityPub::Serializer include RoutingHelper + context :security + + context_extensions :manually_approves_followers, :featured, :also_known_as, + :moved_to, :property_value, :hashtag, :emoji + attributes :id, :type, :following, :followers, :inbox, :outbox, :featured, :preferred_username, :name, :summary, @@ -16,7 +21,7 @@ class ActivityPub::ActorSerializer < ActiveModel::Serializer attribute :moved_to, if: :moved? attribute :also_known_as, if: :also_known_as? - class EndpointsSerializer < ActiveModel::Serializer + class EndpointsSerializer < ActivityPub::Serializer include RoutingHelper attributes :shared_inbox @@ -124,7 +129,7 @@ class ActivityPub::ActorSerializer < ActiveModel::Serializer class CustomEmojiSerializer < ActivityPub::EmojiSerializer end - class TagSerializer < ActiveModel::Serializer + class TagSerializer < ActivityPub::Serializer include RoutingHelper attributes :type, :href, :name @@ -142,7 +147,7 @@ class ActivityPub::ActorSerializer < ActiveModel::Serializer end end - class Account::FieldSerializer < ActiveModel::Serializer + class Account::FieldSerializer < ActivityPub::Serializer attributes :type, :name, :value def type diff --git a/app/serializers/activitypub/add_serializer.rb b/app/serializers/activitypub/add_serializer.rb index c0906e8d0..6f5aab17f 100644 --- a/app/serializers/activitypub/add_serializer.rb +++ b/app/serializers/activitypub/add_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::AddSerializer < ActiveModel::Serializer +class ActivityPub::AddSerializer < ActivityPub::Serializer include RoutingHelper attributes :type, :actor, :target diff --git a/app/serializers/activitypub/block_serializer.rb b/app/serializers/activitypub/block_serializer.rb index 624ce2fce..e6c69329d 100644 --- a/app/serializers/activitypub/block_serializer.rb +++ b/app/serializers/activitypub/block_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::BlockSerializer < ActiveModel::Serializer +class ActivityPub::BlockSerializer < ActivityPub::Serializer attributes :id, :type, :actor attribute :virtual_object, key: :object diff --git a/app/serializers/activitypub/collection_serializer.rb b/app/serializers/activitypub/collection_serializer.rb index b03609957..da1ba735f 100644 --- a/app/serializers/activitypub/collection_serializer.rb +++ b/app/serializers/activitypub/collection_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::CollectionSerializer < ActiveModel::Serializer +class ActivityPub::CollectionSerializer < ActivityPub::Serializer def self.serializer_for(model, options) return ActivityPub::NoteSerializer if model.class.name == 'Status' return ActivityPub::CollectionSerializer if model.class.name == 'ActivityPub::CollectionPresenter' diff --git a/app/serializers/activitypub/delete_actor_serializer.rb b/app/serializers/activitypub/delete_actor_serializer.rb index ddf59be97..a6c5e2385 100644 --- a/app/serializers/activitypub/delete_actor_serializer.rb +++ b/app/serializers/activitypub/delete_actor_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::DeleteActorSerializer < ActiveModel::Serializer +class ActivityPub::DeleteActorSerializer < ActivityPub::Serializer attributes :id, :type, :actor, :to attribute :virtual_object, key: :object diff --git a/app/serializers/activitypub/delete_serializer.rb b/app/serializers/activitypub/delete_serializer.rb index 5012a8383..a7d5bd469 100644 --- a/app/serializers/activitypub/delete_serializer.rb +++ b/app/serializers/activitypub/delete_serializer.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true -class ActivityPub::DeleteSerializer < ActiveModel::Serializer - class TombstoneSerializer < ActiveModel::Serializer +class ActivityPub::DeleteSerializer < ActivityPub::Serializer + class TombstoneSerializer < ActivityPub::Serializer + context_extensions :atom_uri + attributes :id, :type, :atom_uri def id diff --git a/app/serializers/activitypub/emoji_serializer.rb b/app/serializers/activitypub/emoji_serializer.rb index 7b06b1e5d..4dc38f3ea 100644 --- a/app/serializers/activitypub/emoji_serializer.rb +++ b/app/serializers/activitypub/emoji_serializer.rb @@ -1,8 +1,10 @@ # frozen_string_literal: true -class ActivityPub::EmojiSerializer < ActiveModel::Serializer +class ActivityPub::EmojiSerializer < ActivityPub::Serializer include RoutingHelper + context_extensions :emoji + attributes :id, :type, :name, :updated has_one :icon, serializer: ActivityPub::ImageSerializer diff --git a/app/serializers/activitypub/flag_serializer.rb b/app/serializers/activitypub/flag_serializer.rb index 1e7a46dd9..2f2a707d3 100644 --- a/app/serializers/activitypub/flag_serializer.rb +++ b/app/serializers/activitypub/flag_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::FlagSerializer < ActiveModel::Serializer +class ActivityPub::FlagSerializer < ActivityPub::Serializer attributes :id, :type, :actor, :content attribute :virtual_object, key: :object diff --git a/app/serializers/activitypub/follow_serializer.rb b/app/serializers/activitypub/follow_serializer.rb index bb204ee8f..9228d7716 100644 --- a/app/serializers/activitypub/follow_serializer.rb +++ b/app/serializers/activitypub/follow_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::FollowSerializer < ActiveModel::Serializer +class ActivityPub::FollowSerializer < ActivityPub::Serializer attributes :id, :type, :actor attribute :virtual_object, key: :object diff --git a/app/serializers/activitypub/image_serializer.rb b/app/serializers/activitypub/image_serializer.rb index 3c08f77e8..1060f9691 100644 --- a/app/serializers/activitypub/image_serializer.rb +++ b/app/serializers/activitypub/image_serializer.rb @@ -1,8 +1,10 @@ # frozen_string_literal: true -class ActivityPub::ImageSerializer < ActiveModel::Serializer +class ActivityPub::ImageSerializer < ActivityPub::Serializer include RoutingHelper + context_extensions :focal_point + attributes :type, :media_type, :url attribute :focal_point, if: :focal_point? diff --git a/app/serializers/activitypub/like_serializer.rb b/app/serializers/activitypub/like_serializer.rb index c1a7ff6f6..0f170ddb4 100644 --- a/app/serializers/activitypub/like_serializer.rb +++ b/app/serializers/activitypub/like_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::LikeSerializer < ActiveModel::Serializer +class ActivityPub::LikeSerializer < ActivityPub::Serializer attributes :id, :type, :actor attribute :virtual_object, key: :object diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb index 553f333d8..d11cfa59a 100644 --- a/app/serializers/activitypub/note_serializer.rb +++ b/app/serializers/activitypub/note_serializer.rb @@ -1,6 +1,9 @@ # frozen_string_literal: true -class ActivityPub::NoteSerializer < ActiveModel::Serializer +class ActivityPub::NoteSerializer < ActivityPub::Serializer + context_extensions :atom_uri, :conversation, :sensitive, + :hashtag, :emoji, :focal_point + attributes :id, :type, :summary, :in_reply_to, :published, :url, :attributed_to, :to, :cc, :sensitive, @@ -26,7 +29,7 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer end def type - object.poll ? 'Question' : 'Note' + object.preloadable_poll ? 'Question' : 'Note' end def summary @@ -122,32 +125,32 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer end def poll_options - object.poll.loaded_options + object.preloadable_poll.loaded_options end def poll_and_multiple? - object.poll&.multiple? + object.preloadable_poll&.multiple? end def poll_and_not_multiple? - object.poll && !object.poll.multiple? + object.preloadable_poll && !object.preloadable_poll.multiple? end def closed - object.poll.expires_at.iso8601 + object.preloadable_poll.expires_at.iso8601 end alias end_time closed def poll_and_expires? - object.poll&.expires_at&.present? + object.preloadable_poll&.expires_at&.present? end def poll_and_expired? - object.poll&.expired? + object.preloadable_poll&.expired? end - class MediaAttachmentSerializer < ActiveModel::Serializer + class MediaAttachmentSerializer < ActivityPub::Serializer include RoutingHelper attributes :type, :media_type, :url, :name @@ -178,7 +181,7 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer end end - class MentionSerializer < ActiveModel::Serializer + class MentionSerializer < ActivityPub::Serializer attributes :type, :href, :name def type @@ -194,7 +197,7 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer end end - class TagSerializer < ActiveModel::Serializer + class TagSerializer < ActivityPub::Serializer include RoutingHelper attributes :type, :href, :name @@ -215,8 +218,8 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer class CustomEmojiSerializer < ActivityPub::EmojiSerializer end - class OptionSerializer < ActiveModel::Serializer - class RepliesSerializer < ActiveModel::Serializer + class OptionSerializer < ActivityPub::Serializer + class RepliesSerializer < ActivityPub::Serializer attributes :type, :total_items def type diff --git a/app/serializers/activitypub/public_key_serializer.rb b/app/serializers/activitypub/public_key_serializer.rb index 38e9e93ba..62ed49e81 100644 --- a/app/serializers/activitypub/public_key_serializer.rb +++ b/app/serializers/activitypub/public_key_serializer.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true -class ActivityPub::PublicKeySerializer < ActiveModel::Serializer +class ActivityPub::PublicKeySerializer < ActivityPub::Serializer + context :security + attributes :id, :owner, :public_key_pem def id diff --git a/app/serializers/activitypub/reject_follow_serializer.rb b/app/serializers/activitypub/reject_follow_serializer.rb index 7814f4f57..4996c9a3c 100644 --- a/app/serializers/activitypub/reject_follow_serializer.rb +++ b/app/serializers/activitypub/reject_follow_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::RejectFollowSerializer < ActiveModel::Serializer +class ActivityPub::RejectFollowSerializer < ActivityPub::Serializer attributes :id, :type, :actor has_one :object, serializer: ActivityPub::FollowSerializer diff --git a/app/serializers/activitypub/remove_serializer.rb b/app/serializers/activitypub/remove_serializer.rb index c2a5ae1b3..7fefda59d 100644 --- a/app/serializers/activitypub/remove_serializer.rb +++ b/app/serializers/activitypub/remove_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::RemoveSerializer < ActiveModel::Serializer +class ActivityPub::RemoveSerializer < ActivityPub::Serializer include RoutingHelper attributes :type, :actor, :target diff --git a/app/serializers/activitypub/undo_announce_serializer.rb b/app/serializers/activitypub/undo_announce_serializer.rb index 4fc042727..6758af679 100644 --- a/app/serializers/activitypub/undo_announce_serializer.rb +++ b/app/serializers/activitypub/undo_announce_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::UndoAnnounceSerializer < ActiveModel::Serializer +class ActivityPub::UndoAnnounceSerializer < ActivityPub::Serializer attributes :id, :type, :actor, :to has_one :object, serializer: ActivityPub::ActivitySerializer diff --git a/app/serializers/activitypub/undo_block_serializer.rb b/app/serializers/activitypub/undo_block_serializer.rb index 2f43d8402..b4f049377 100644 --- a/app/serializers/activitypub/undo_block_serializer.rb +++ b/app/serializers/activitypub/undo_block_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::UndoBlockSerializer < ActiveModel::Serializer +class ActivityPub::UndoBlockSerializer < ActivityPub::Serializer attributes :id, :type, :actor has_one :object, serializer: ActivityPub::BlockSerializer diff --git a/app/serializers/activitypub/undo_follow_serializer.rb b/app/serializers/activitypub/undo_follow_serializer.rb index e5b7f143d..9b3e0ca3c 100644 --- a/app/serializers/activitypub/undo_follow_serializer.rb +++ b/app/serializers/activitypub/undo_follow_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::UndoFollowSerializer < ActiveModel::Serializer +class ActivityPub::UndoFollowSerializer < ActivityPub::Serializer attributes :id, :type, :actor has_one :object, serializer: ActivityPub::FollowSerializer diff --git a/app/serializers/activitypub/undo_like_serializer.rb b/app/serializers/activitypub/undo_like_serializer.rb index 25f4ccaae..20c786cb7 100644 --- a/app/serializers/activitypub/undo_like_serializer.rb +++ b/app/serializers/activitypub/undo_like_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::UndoLikeSerializer < ActiveModel::Serializer +class ActivityPub::UndoLikeSerializer < ActivityPub::Serializer attributes :id, :type, :actor has_one :object, serializer: ActivityPub::LikeSerializer diff --git a/app/serializers/activitypub/update_poll_serializer.rb b/app/serializers/activitypub/update_poll_serializer.rb index f7933346f..b894f309f 100644 --- a/app/serializers/activitypub/update_poll_serializer.rb +++ b/app/serializers/activitypub/update_poll_serializer.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -class ActivityPub::UpdatePollSerializer < ActiveModel::Serializer +class ActivityPub::UpdatePollSerializer < ActivityPub::Serializer attributes :id, :type, :actor, :to has_one :object, serializer: ActivityPub::NoteSerializer def id - [ActivityPub::TagManager.instance.uri_for(object), '#updates/', object.poll.updated_at.to_i].join + [ActivityPub::TagManager.instance.uri_for(object), '#updates/', object.preloadable_poll.updated_at.to_i].join end def type diff --git a/app/serializers/activitypub/update_serializer.rb b/app/serializers/activitypub/update_serializer.rb index 48d7a1929..a5eb857d3 100644 --- a/app/serializers/activitypub/update_serializer.rb +++ b/app/serializers/activitypub/update_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActivityPub::UpdateSerializer < ActiveModel::Serializer +class ActivityPub::UpdateSerializer < ActivityPub::Serializer attributes :id, :type, :actor, :to has_one :object, serializer: ActivityPub::ActorSerializer diff --git a/app/serializers/activitypub/vote_serializer.rb b/app/serializers/activitypub/vote_serializer.rb index 248190404..71ef5c77e 100644 --- a/app/serializers/activitypub/vote_serializer.rb +++ b/app/serializers/activitypub/vote_serializer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -class ActivityPub::VoteSerializer < ActiveModel::Serializer - class NoteSerializer < ActiveModel::Serializer +class ActivityPub::VoteSerializer < ActivityPub::Serializer + class NoteSerializer < ActivityPub::Serializer attributes :id, :type, :name, :attributed_to, :in_reply_to, :to diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index 7185121d6..a7b797368 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -23,7 +23,7 @@ class REST::StatusSerializer < ActiveModel::Serializer has_many :emojis, serializer: REST::CustomEmojiSerializer has_one :preview_card, key: :card, serializer: REST::PreviewCardSerializer - has_one :poll, serializer: REST::PollSerializer + has_one :preloadable_poll, key: :poll, serializer: REST::PollSerializer def id object.id.to_s |