diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-07-13 02:16:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-13 02:16:06 +0200 |
commit | e55dce3176b7ac0a23a8a652c2626707a1b74dbb (patch) | |
tree | 12d129849083dc0d17e372cb13d549c39dc40d51 /app/workers/activitypub | |
parent | 401559c376078ef98e11c3034977b835b4086b5b (diff) |
Add federation relay support (#7998)
* Add federation relay support * Add admin UI for managing relays * Include actor on relay-related activities * Fix i18n
Diffstat (limited to 'app/workers/activitypub')
-rw-r--r-- | app/workers/activitypub/distribution_worker.rb | 12 | ||||
-rw-r--r-- | app/workers/activitypub/update_distribution_worker.rb | 10 |
2 files changed, 21 insertions, 1 deletions
diff --git a/app/workers/activitypub/distribution_worker.rb b/app/workers/activitypub/distribution_worker.rb index 14bb933c0..c2bfd4f2f 100644 --- a/app/workers/activitypub/distribution_worker.rb +++ b/app/workers/activitypub/distribution_worker.rb @@ -14,6 +14,8 @@ class ActivityPub::DistributionWorker ActivityPub::DeliveryWorker.push_bulk(inboxes) do |inbox_url| [signed_payload, @account.id, inbox_url] end + + relay! if relayable? rescue ActiveRecord::RecordNotFound true end @@ -24,6 +26,10 @@ class ActivityPub::DistributionWorker @status.direct_visibility? end + def relayable? + @status.public_visibility? + end + def inboxes @inboxes ||= @account.followers.inboxes end @@ -39,4 +45,10 @@ class ActivityPub::DistributionWorker adapter: ActivityPub::Adapter ).as_json end + + def relay! + ActivityPub::DeliveryWorker.push_bulk(Relay.enabled.pluck(:inbox_url)) do |inbox_url| + [signed_payload, @account.id, inbox_url] + end + end end diff --git a/app/workers/activitypub/update_distribution_worker.rb b/app/workers/activitypub/update_distribution_worker.rb index f3377dcec..87efafb3e 100644 --- a/app/workers/activitypub/update_distribution_worker.rb +++ b/app/workers/activitypub/update_distribution_worker.rb @@ -9,7 +9,11 @@ class ActivityPub::UpdateDistributionWorker @account = Account.find(account_id) ActivityPub::DeliveryWorker.push_bulk(inboxes) do |inbox_url| - [payload, @account.id, inbox_url] + [signed_payload, @account.id, inbox_url] + end + + ActivityPub::DeliveryWorker.push_bulk(Relay.enabled.pluck(:inbox_url)) do |inbox_url| + [signed_payload, @account.id, inbox_url] end rescue ActiveRecord::RecordNotFound true @@ -21,6 +25,10 @@ class ActivityPub::UpdateDistributionWorker @inboxes ||= @account.followers.inboxes end + def signed_payload + @signed_payload ||= Oj.dump(ActivityPub::LinkedDataSignature.new(payload).sign!(@account)) + end + def payload @payload ||= ActiveModelSerializers::SerializableResource.new( @account, |