File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ # Obsolete but kept around to make sure existing jobs do not fail after upgrade.
4+ # Should be removed in a subsequent release.
5+
6+ class ActivityPub ::ReplyDistributionWorker
7+ include Sidekiq ::Worker
8+
9+ sidekiq_options queue : 'push'
10+
11+ def perform ( status_id )
12+ @status = Status . find ( status_id )
13+ @account = @status . thread &.account
14+
15+ return unless @account . present? && @status . distributable?
16+
17+ ActivityPub ::DeliveryWorker . push_bulk ( inboxes ) do |inbox_url |
18+ [ payload , @status . account_id , inbox_url ]
19+ end
20+ rescue ActiveRecord ::RecordNotFound
21+ true
22+ end
23+
24+ private
25+
26+ def inboxes
27+ @inboxes ||= @account . followers . inboxes
28+ end
29+
30+ def signed_payload
31+ Oj . dump ( ActivityPub ::LinkedDataSignature . new ( unsigned_payload ) . sign! ( @status . account ) )
32+ end
33+
34+ def unsigned_payload
35+ ActiveModelSerializers ::SerializableResource . new (
36+ @status ,
37+ serializer : ActivityPub ::ActivitySerializer ,
38+ adapter : ActivityPub ::Adapter
39+ ) . as_json
40+ end
41+
42+ def payload
43+ @payload ||= @status . distributable? ? signed_payload : Oj . dump ( unsigned_payload )
44+ end
45+ end
You can’t perform that action at this time.
0 commit comments