about summary refs log tree commit diff
path: root/app/serializers/activitypub
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>2018-01-04 02:08:57 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-01-03 18:08:57 +0100
commit161c72d66d25bb8f5ff492e36a8521c701ab8afc (patch)
treed57b674958a4353bba0cf91ba4197748a66fc2f5 /app/serializers/activitypub
parent53d99ebf4f54c25fa58709e9dc05730479ea7d02 (diff)
Allow to dereference Follow object for ActivityPub (#5772)
* Allow to dereference Follow object for ActivityPub

* Accept IRI as object representation for Accept activity
Diffstat (limited to 'app/serializers/activitypub')
-rw-r--r--app/serializers/activitypub/follow_serializer.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/serializers/activitypub/follow_serializer.rb b/app/serializers/activitypub/follow_serializer.rb
index 86c9992fe..eecd64701 100644
--- a/app/serializers/activitypub/follow_serializer.rb
+++ b/app/serializers/activitypub/follow_serializer.rb
@@ -1,11 +1,12 @@
 # frozen_string_literal: true
 
 class ActivityPub::FollowSerializer < ActiveModel::Serializer
-  attributes :id, :type, :actor
+  attributes :type, :actor
+  attribute :id, if: :dereferencable?
   attribute :virtual_object, key: :object
 
   def id
-    [ActivityPub::TagManager.instance.uri_for(object.account), '#follows/', object.id].join
+    ActivityPub::TagManager.instance.uri_for(object)
   end
 
   def type
@@ -19,4 +20,8 @@ class ActivityPub::FollowSerializer < ActiveModel::Serializer
   def virtual_object
     ActivityPub::TagManager.instance.uri_for(object.target_account)
   end
+
+  def dereferencable?
+    object.respond_to?(:object_type)
+  end
 end