about summary refs log tree commit diff
path: root/app/serializers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-08-26 19:55:10 +0200
committerGitHub <noreply@github.com>2017-08-26 19:55:10 +0200
commit0d5d11eeff048a5022a6eef68d299856f5bb9860 (patch)
tree04c60da71049a85fbdbccdb6e3e4f5c5f0dc4ae0 /app/serializers
parent0397c58b61d8a364ff488fc5631bfc751903c242 (diff)
Add _:inReplyToAtomUri to ActivityPub (#4702)
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/activitypub/activity_serializer.rb6
-rw-r--r--app/serializers/activitypub/note_serializer.rb7
2 files changed, 12 insertions, 1 deletions
diff --git a/app/serializers/activitypub/activity_serializer.rb b/app/serializers/activitypub/activity_serializer.rb
index d20ee9920..349495e84 100644
--- a/app/serializers/activitypub/activity_serializer.rb
+++ b/app/serializers/activitypub/activity_serializer.rb
@@ -10,7 +10,7 @@ class ActivityPub::ActivitySerializer < ActiveModel::Serializer
   end
 
   def type
-    object.reblog? ? 'Announce' : 'Create'
+    announce? ? 'Announce' : 'Create'
   end
 
   def actor
@@ -24,4 +24,8 @@ class ActivityPub::ActivitySerializer < ActiveModel::Serializer
   def cc
     ActivityPub::TagManager.instance.cc(object)
   end
+
+  def announce?
+    object.reblog?
+  end
 end
diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb
index 4061b9ce4..15031dfdc 100644
--- a/app/serializers/activitypub/note_serializer.rb
+++ b/app/serializers/activitypub/note_serializer.rb
@@ -9,6 +9,7 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
   has_many :virtual_tags, key: :tag
 
   attribute :atom_uri, key: '_:atomUri', if: :local?
+  attribute :in_reply_to_atom_uri, key: '_:inReplyToAtomUri'
 
   def id
     ActivityPub::TagManager.instance.uri_for(object)
@@ -64,6 +65,12 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
     ::TagManager.instance.uri_for(object)
   end
 
+  def in_reply_to_atom_uri
+    return unless object.reply?
+
+    ::TagManager.instance.uri_for(object.thread)
+  end
+
   def local?
     object.account.local?
   end