about summary refs log tree commit diff
path: root/app/workers/activitypub/thread_resolve_worker.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers/activitypub/thread_resolve_worker.rb')
-rw-r--r--app/workers/activitypub/thread_resolve_worker.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/workers/activitypub/thread_resolve_worker.rb b/app/workers/activitypub/thread_resolve_worker.rb
new file mode 100644
index 000000000..4ef762d06
--- /dev/null
+++ b/app/workers/activitypub/thread_resolve_worker.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class ActivityPub::ThreadResolveWorker
+  include Sidekiq::Worker
+
+  sidekiq_options queue: 'pull', retry: false
+
+  def perform(child_status_id, parent_uri)
+    child_status  = Status.find(child_status_id)
+    parent_status = ActivityPub::FetchRemoteStatusService.new.call(parent_uri)
+
+    return if parent_status.nil?
+
+    child_status.thread = parent_status
+    child_status.save!
+  end
+end