diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-10-30 15:03:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-30 15:03:55 +0100 |
commit | be202f9377fecfc801befac0be6d11d9f0039c5d (patch) | |
tree | 0069e37db8bfebc5475c5627c700251ad60d9210 /app/lib | |
parent | 47b8d195e6ea5bc5f3cd4fe3a5be0b25ec322f10 (diff) |
Accept the same payload in multiple inboxes and deliver (#9150)
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/activitypub/activity/create.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index baa05e14c..45079e2b3 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -10,7 +10,12 @@ class ActivityPub::Activity::Create < ActivityPub::Activity RedisLock.acquire(lock_options) do |lock| if lock.acquired? @status = find_existing_status - process_status if @status.nil? + + if @status.nil? + process_status + elsif @options[:delivered_to_account_id].present? + postprocess_audience_and_deliver + end else raise Mastodon::RaceConditionError end @@ -99,6 +104,19 @@ class ActivityPub::Activity::Create < ActivityPub::Activity @params[:visibility] = :limited end + def postprocess_audience_and_deliver + return if @status.mentions.find_by(account_id: @options[:delivered_to_account_id]) + + delivered_to_account = Account.find(@options[:delivered_to_account_id]) + + @status.mentions.create(account: delivered_to_account, silent: true) + @status.update(visibility: :limited) if @status.direct_visibility? + + return unless delivered_to_account.following?(@account) + + FeedInsertWorker.perform_async(@status.id, delivered_to_account.id, :home) + end + def attach_tags(status) @tags.each do |tag| status.tags << tag |