about summary refs log tree commit diff
path: root/app/serializers/activitypub
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-09-07 14:16:54 +0200
committerGitHub <noreply@github.com>2020-09-07 14:16:54 +0200
commit437d71bddf967573df3912ee5976f7c5a5a7b4c7 (patch)
tree322231d7d50704edf8da762b69ee22c9850f2ce3 /app/serializers/activitypub
parentd967251fdc3826ad27d30e55258cfa4cdfd7c871 (diff)
parente5f934ddf0aa4ef9efbf45751bc00bebff768d99 (diff)
Merge pull request #1418 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/serializers/activitypub')
-rw-r--r--app/serializers/activitypub/actor_serializer.rb8
-rw-r--r--app/serializers/activitypub/collection_serializer.rb2
-rw-r--r--app/serializers/activitypub/hashtag_serializer.rb23
3 files changed, 31 insertions, 2 deletions
diff --git a/app/serializers/activitypub/actor_serializer.rb b/app/serializers/activitypub/actor_serializer.rb
index 627d4446b..5d2741b17 100644
--- a/app/serializers/activitypub/actor_serializer.rb
+++ b/app/serializers/activitypub/actor_serializer.rb
@@ -10,7 +10,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
                      :discoverable, :olm
 
   attributes :id, :type, :following, :followers,
-             :inbox, :outbox, :featured,
+             :inbox, :outbox, :featured, :featured_tags,
              :preferred_username, :name, :summary,
              :url, :manually_approves_followers,
              :discoverable
@@ -74,13 +74,17 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
   end
 
   def outbox
-    account_outbox_url(object)
+    object.instance_actor? ? instance_actor_outbox_url : account_outbox_url(object)
   end
 
   def featured
     account_collection_url(object, :featured)
   end
 
+  def featured_tags
+    account_collection_url(object, :tags)
+  end
+
   def endpoints
     object
   end
diff --git a/app/serializers/activitypub/collection_serializer.rb b/app/serializers/activitypub/collection_serializer.rb
index ea7af5433..34026a6b5 100644
--- a/app/serializers/activitypub/collection_serializer.rb
+++ b/app/serializers/activitypub/collection_serializer.rb
@@ -16,6 +16,8 @@ class ActivityPub::CollectionSerializer < ActivityPub::Serializer
       ActivityPub::NoteSerializer
     when 'Device'
       ActivityPub::DeviceSerializer
+    when 'FeaturedTag'
+      ActivityPub::HashtagSerializer
     when 'ActivityPub::CollectionPresenter'
       ActivityPub::CollectionSerializer
     when 'String'
diff --git a/app/serializers/activitypub/hashtag_serializer.rb b/app/serializers/activitypub/hashtag_serializer.rb
new file mode 100644
index 000000000..1a56e4dfe
--- /dev/null
+++ b/app/serializers/activitypub/hashtag_serializer.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class ActivityPub::HashtagSerializer < ActivityPub::Serializer
+  include RoutingHelper
+
+  attributes :type, :href, :name
+
+  def type
+    'Hashtag'
+  end
+
+  def name
+    "##{object.name}"
+  end
+
+  def href
+    if object.class.name == 'FeaturedTag'
+      short_account_tag_url(object.account, object.tag)
+    else
+      tag_url(object)
+    end
+  end
+end