about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-08-29 16:11:05 +0200
committerGitHub <noreply@github.com>2017-08-29 16:11:05 +0200
commit4c76402ba1d355061e7e208b7a2f8251388a38e1 (patch)
treef76f71be7326e16ccaeaf74402f36c79973b734b /app/models
parent9958eba356210f1d0b89db368e17bbd72358e097 (diff)
Serialize ActivityPub alternate link into OStatus deletes, handle it (#4730)
Requires moving Atom rendering from DistributionWorker (where
`stream_entry.status` is already nil) to inline (where
`stream_entry.status.destroyed?` is true) and distributing that.

Unfortunately, such XML renderings can no longer be easily chained
together into one payload of n items.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/status.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 3dc83ad1f..abd902cd7 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -51,6 +51,7 @@ class Status < ApplicationRecord
 
   has_one :notification, as: :activity, dependent: :destroy
   has_one :preview_card, dependent: :destroy
+  has_one :stream_entry, as: :activity, inverse_of: :status
 
   validates :uri, uniqueness: true, unless: :local?
   validates :text, presence: true, unless: :reblog?
@@ -90,7 +91,11 @@ class Status < ApplicationRecord
   end
 
   def verb
-    reblog? ? :share : :post
+    if destroyed?
+      :delete
+    else
+      reblog? ? :share : :post
+    end
   end
 
   def object_type
@@ -110,7 +115,11 @@ class Status < ApplicationRecord
   end
 
   def title
-    reblog? ? "#{account.acct} shared a status by #{reblog.account.acct}" : "New status by #{account.acct}"
+    if destroyed?
+      "#{account.acct} deleted status"
+    else
+      reblog? ? "#{account.acct} shared a status by #{reblog.account.acct}" : "New status by #{account.acct}"
+    end
   end
 
   def hidden?