about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-02-10 00:15:30 +0100
committerGitHub <noreply@github.com>2022-02-10 00:15:30 +0100
commit63002cde03a836b4510aca5da564504ecaedb5e9 (patch)
treef6749dd6bafae30c8708559da037668f5585b16e /app/workers
parent20a3564ab280a004cc7c075c00f63e70b1d65e07 (diff)
Add editing for published statuses (#17320)
* Add editing for published statuses

* Fix change of multiple-choice boolean in poll not resetting votes

* Remove the ability to update existing media attachments for now
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/activitypub/status_update_distribution_worker.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/workers/activitypub/status_update_distribution_worker.rb b/app/workers/activitypub/status_update_distribution_worker.rb
new file mode 100644
index 000000000..261aaa0cc
--- /dev/null
+++ b/app/workers/activitypub/status_update_distribution_worker.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class ActivityPub::StatusUpdateDistributionWorker < ActivityPub::DistributionWorker
+  # Distribute an profile update to servers that might have a copy
+  # of the account in question
+  def perform(status_id, options = {})
+    @options = options.with_indifferent_access
+    @status  = Status.find(status_id)
+
+    distribute!
+  rescue ActiveRecord::RecordNotFound
+    true
+  end
+
+  protected
+
+  def activity
+    ActivityPub::ActivityPresenter.new(
+      id: [ActivityPub::TagManager.instance.uri_for(@status), '#updates/', @status.edited_at.to_i].join,
+      type: 'Update',
+      actor: ActivityPub::TagManager.instance.uri_for(@status.account),
+      published: @status.edited_at,
+      to: ActivityPub::TagManager.instance.to(@status),
+      cc: ActivityPub::TagManager.instance.cc(@status),
+      virtual_object: @status
+    )
+  end
+end