diff options
author | Thibaut Girka <thib@sitedethib.com> | 2019-01-02 13:45:18 +0100 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2019-01-02 15:36:53 +0100 |
commit | 571d219bb917cefcca7419a0ad4e3889689d5f6a (patch) | |
tree | 6ab91adcb2c164fd027708e58f5fb96c52474007 /app/workers/activitypub/reply_distribution_worker.rb | |
parent | b300948526d967aaf5608c93546ee0d54940c0ef (diff) | |
parent | 66436d08959998be20c6c6bf631177d8c1f3e0d1 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts manually resolved: - app/services/post_status_service.rb - config/locales/simple_form.pl.yml - config/routes.rb - config/webpack/loaders/sass.js - config/webpack/shared.js - package.json - yarn.lock
Diffstat (limited to 'app/workers/activitypub/reply_distribution_worker.rb')
-rw-r--r-- | app/workers/activitypub/reply_distribution_worker.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/app/workers/activitypub/reply_distribution_worker.rb b/app/workers/activitypub/reply_distribution_worker.rb index c0ed3a1f4..d8fea6c4e 100644 --- a/app/workers/activitypub/reply_distribution_worker.rb +++ b/app/workers/activitypub/reply_distribution_worker.rb @@ -1,5 +1,8 @@ # frozen_string_literal: true +# Obsolete but kept around to make sure existing jobs do not fail after upgrade. +# Should be removed in a subsequent release. + class ActivityPub::ReplyDistributionWorker include Sidekiq::Worker @@ -12,7 +15,7 @@ class ActivityPub::ReplyDistributionWorker return unless @account.present? && @status.distributable? ActivityPub::DeliveryWorker.push_bulk(inboxes) do |inbox_url| - [signed_payload, @status.account_id, inbox_url] + [payload, @status.account_id, inbox_url] end rescue ActiveRecord::RecordNotFound true @@ -25,14 +28,18 @@ class ActivityPub::ReplyDistributionWorker end def signed_payload - @signed_payload ||= Oj.dump(ActivityPub::LinkedDataSignature.new(payload).sign!(@status.account)) + Oj.dump(ActivityPub::LinkedDataSignature.new(unsigned_payload).sign!(@status.account)) end - def payload - @payload ||= ActiveModelSerializers::SerializableResource.new( + def unsigned_payload + ActiveModelSerializers::SerializableResource.new( @status, serializer: ActivityPub::ActivitySerializer, adapter: ActivityPub::Adapter ).as_json end + + def payload + @payload ||= @status.distributable? ? signed_payload : Oj.dump(unsigned_payload) + end end |