diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-11-12 17:42:53 -0600 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-11-14 17:39:08 -0600 |
commit | f60e0b62f4e5300645f235983e5b75bcf16b370d (patch) | |
tree | 0c437e6600b7a8bdf806d63fa76ce751bbe66d58 /app/serializers/activitypub | |
parent | ec3abd7c87116ad2df5b1da5701afe68a7f74844 (diff) | |
parent | 265b26489a9214a6c98a4dfa88f08ce490211ebc (diff) |
Merge remote-tracking branch 'upstream/master' into merge-glitch
Diffstat (limited to 'app/serializers/activitypub')
-rw-r--r-- | app/serializers/activitypub/actor_serializer.rb | 33 | ||||
-rw-r--r-- | app/serializers/activitypub/note_serializer.rb | 4 |
2 files changed, 27 insertions, 10 deletions
diff --git a/app/serializers/activitypub/actor_serializer.rb b/app/serializers/activitypub/actor_serializer.rb index a56626532..0c6205d7f 100644 --- a/app/serializers/activitypub/actor_serializer.rb +++ b/app/serializers/activitypub/actor_serializer.rb @@ -7,7 +7,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer context_extensions :manually_approves_followers, :featured, :also_known_as, :moved_to, :property_value, :identity_proof, - :discoverable, :olm + :discoverable, :olm, :suspended attributes :id, :type, :following, :followers, :inbox, :outbox, :featured, :featured_tags, @@ -23,6 +23,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer attribute :devices, unless: :instance_actor? attribute :moved_to, if: :moved? attribute :also_known_as, if: :also_known_as? + attribute :suspended, if: :suspended? context_extensions :require_dereference, :show_replies, :private, :require_auth, :metadata, :server_metadata attributes :require_dereference, :show_replies, :show_unlisted, :private, :require_auth @@ -43,7 +44,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer has_one :icon, serializer: ActivityPub::ImageSerializer, if: :avatar_exists? has_one :image, serializer: ActivityPub::ImageSerializer, if: :header_exists? - delegate :moved?, :instance_actor?, to: :object + delegate :suspended?, :instance_actor?, to: :object def id object.instance_actor? ? instance_actor_url : account_url(object) @@ -97,12 +98,16 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer object.username end + def discoverable + object.suspended? ? false : (object.discoverable || false) + end + def name - object.display_name + object.suspended? ? '' : object.display_name end def summary - Formatter.instance.simplified_format(object) + object.suspended? ? '' : Formatter.instance.simplified_format(object) end def icon @@ -117,28 +122,32 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer object end + def suspended + object.suspended? + end + def url object.instance_actor? ? about_more_url(instance_actor: true) : short_account_url(object) end def avatar_exists? - object.avatar? + !object.suspended? && object.avatar? end def header_exists? - object.header? + !object.suspended? && object.header? end def manually_approves_followers - object.locked + object.suspended? ? false : object.locked end def virtual_tags - object.emojis + object.tags + object.suspended? ? [] : (object.emojis + object.tags) end def virtual_attachments - object.fields + object.identity_proofs.active + object.suspended? ? [] : (object.fields + object.identity_proofs.active) end def metadata @@ -153,8 +162,12 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer ActivityPub::TagManager.instance.uri_for(object.moved_to_account) end + def moved? + !object.suspended? && object.moved? + end + def also_known_as? - !object.also_known_as.empty? + !object.suspended? && !object.also_known_as.empty? end class CustomEmojiSerializer < ActivityPub::EmojiSerializer diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb index b973f69ec..0b2ab0cfd 100644 --- a/app/serializers/activitypub/note_serializer.rb +++ b/app/serializers/activitypub/note_serializer.rb @@ -137,6 +137,10 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer ActivityPub::TagManager.instance.cc(object, target_domain: instance_options[:target_domain]) end + def sensitive + object.account.sensitized? || object.sensitive + end + def virtual_tags object.active_mentions.to_a.sort_by(&:id) + object.tags + object.emojis end |