about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-07-17 10:57:04 +0200
committerGitHub <noreply@github.com>2017-07-17 10:57:04 +0200
commitd4b097a88cb43105be86ea06fe4a4dd7830b8416 (patch)
treed8bbf433d31bb6c903d1cb1466c70123b059d2e4 /app
parent902c5cf7cafcd08caaf4fc75bd3fbfe41e5a9ad7 (diff)
Add missing ActivityPub representations (#4230)
- Follow, undo follow
- Accept follow, reject follow
- Like, undo like
- Block, undo block
- Delete (note)
- Update (actor)
Diffstat (limited to 'app')
-rw-r--r--app/serializers/activitypub/accept_follow_serializer.rb15
-rw-r--r--app/serializers/activitypub/block_serializer.rb18
-rw-r--r--app/serializers/activitypub/delete_serializer.rb18
-rw-r--r--app/serializers/activitypub/follow_serializer.rb18
-rw-r--r--app/serializers/activitypub/like_serializer.rb18
-rw-r--r--app/serializers/activitypub/reject_follow_serializer.rb15
-rw-r--r--app/serializers/activitypub/undo_block_serializer.rb15
-rw-r--r--app/serializers/activitypub/undo_follow_serializer.rb15
-rw-r--r--app/serializers/activitypub/undo_like_serializer.rb15
-rw-r--r--app/serializers/activitypub/update_serializer.rb15
10 files changed, 162 insertions, 0 deletions
diff --git a/app/serializers/activitypub/accept_follow_serializer.rb b/app/serializers/activitypub/accept_follow_serializer.rb
new file mode 100644
index 000000000..ce900bc78
--- /dev/null
+++ b/app/serializers/activitypub/accept_follow_serializer.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class ActivityPub::AcceptFollowSerializer < ActiveModel::Serializer
+  attributes :type, :actor
+
+  has_one :object, serializer: ActivityPub::FollowSerializer
+
+  def type
+    'Accept'
+  end
+
+  def actor
+    ActivityPub::TagManager.instance.uri_for(object.target_account)
+  end
+end
diff --git a/app/serializers/activitypub/block_serializer.rb b/app/serializers/activitypub/block_serializer.rb
new file mode 100644
index 000000000..a001b213b
--- /dev/null
+++ b/app/serializers/activitypub/block_serializer.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class ActivityPub::BlockSerializer < ActiveModel::Serializer
+  attributes :type, :actor
+  attribute :virtual_object, key: :object
+
+  def type
+    'Block'
+  end
+
+  def actor
+    ActivityPub::TagManager.instance.uri_for(object.account)
+  end
+
+  def virtual_object
+    ActivityPub::TagManager.instance.uri_for(object.target_account)
+  end
+end
diff --git a/app/serializers/activitypub/delete_serializer.rb b/app/serializers/activitypub/delete_serializer.rb
new file mode 100644
index 000000000..77098b1b0
--- /dev/null
+++ b/app/serializers/activitypub/delete_serializer.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class ActivityPub::DeleteSerializer < ActiveModel::Serializer
+  attributes :type, :actor
+  attribute :virtual_object, key: :object
+
+  def type
+    'Delete'
+  end
+
+  def actor
+    ActivityPub::TagManager.instance.uri_for(object.account)
+  end
+
+  def virtual_object
+    ActivityPub::TagManager.instance.uri_for(object)
+  end
+end
diff --git a/app/serializers/activitypub/follow_serializer.rb b/app/serializers/activitypub/follow_serializer.rb
new file mode 100644
index 000000000..1953a2d7b
--- /dev/null
+++ b/app/serializers/activitypub/follow_serializer.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class ActivityPub::FollowSerializer < ActiveModel::Serializer
+  attributes :type, :actor
+  attribute :virtual_object, key: :object
+
+  def type
+    'Follow'
+  end
+
+  def actor
+    ActivityPub::TagManager.instance.uri_for(object.account)
+  end
+
+  def virtual_object
+    ActivityPub::TagManager.instance.uri_for(object.target_account)
+  end
+end
diff --git a/app/serializers/activitypub/like_serializer.rb b/app/serializers/activitypub/like_serializer.rb
new file mode 100644
index 000000000..4226913f5
--- /dev/null
+++ b/app/serializers/activitypub/like_serializer.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class ActivityPub::LikeSerializer < ActiveModel::Serializer
+  attributes :type, :actor
+  attribute :virtual_object, key: :object
+
+  def type
+    'Like'
+  end
+
+  def actor
+    ActivityPub::TagManager.instance.uri_for(object.account)
+  end
+
+  def virtual_object
+    ActivityPub::TagManager.instance.uri_for(object.status)
+  end
+end
diff --git a/app/serializers/activitypub/reject_follow_serializer.rb b/app/serializers/activitypub/reject_follow_serializer.rb
new file mode 100644
index 000000000..28584d627
--- /dev/null
+++ b/app/serializers/activitypub/reject_follow_serializer.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class ActivityPub::RejectFollowSerializer < ActiveModel::Serializer
+  attributes :type, :actor
+
+  has_one :object, serializer: ActivityPub::FollowSerializer
+
+  def type
+    'Reject'
+  end
+
+  def actor
+    ActivityPub::TagManager.instance.uri_for(object.target_account)
+  end
+end
diff --git a/app/serializers/activitypub/undo_block_serializer.rb b/app/serializers/activitypub/undo_block_serializer.rb
new file mode 100644
index 000000000..f71faa729
--- /dev/null
+++ b/app/serializers/activitypub/undo_block_serializer.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class ActivityPub::UndoBlockSerializer < ActiveModel::Serializer
+  attributes :type, :actor
+
+  has_one :object, serializer: ActivityPub::BlockSerializer
+
+  def type
+    'Undo'
+  end
+
+  def actor
+    ActivityPub::TagManager.instance.uri_for(object.account)
+  end
+end
diff --git a/app/serializers/activitypub/undo_follow_serializer.rb b/app/serializers/activitypub/undo_follow_serializer.rb
new file mode 100644
index 000000000..fe91f5f1c
--- /dev/null
+++ b/app/serializers/activitypub/undo_follow_serializer.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class ActivityPub::UndoFollowSerializer < ActiveModel::Serializer
+  attributes :type, :actor
+
+  has_one :object, serializer: ActivityPub::FollowSerializer
+
+  def type
+    'Undo'
+  end
+
+  def actor
+    ActivityPub::TagManager.instance.uri_for(object.account)
+  end
+end
diff --git a/app/serializers/activitypub/undo_like_serializer.rb b/app/serializers/activitypub/undo_like_serializer.rb
new file mode 100644
index 000000000..db9cd1d0d
--- /dev/null
+++ b/app/serializers/activitypub/undo_like_serializer.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class ActivityPub::UndoLikeSerializer < ActiveModel::Serializer
+  attributes :type, :actor
+
+  has_one :object, serializer: ActivityPub::LikeSerializer
+
+  def type
+    'Undo'
+  end
+
+  def actor
+    ActivityPub::TagManager.instance.uri_for(object.account)
+  end
+end
diff --git a/app/serializers/activitypub/update_serializer.rb b/app/serializers/activitypub/update_serializer.rb
new file mode 100644
index 000000000..322305da8
--- /dev/null
+++ b/app/serializers/activitypub/update_serializer.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class ActivityPub::UpdateSerializer < ActiveModel::Serializer
+  attributes :type, :actor
+
+  has_one :object, serializer: ActivityPub::ActorSerializer
+
+  def type
+    'Update'
+  end
+
+  def actor
+    ActivityPub::TagManager.instance.uri_for(object)
+  end
+end