forked from asonix/mastodon
* Add silent column to mentions * Save silent mentions in ActivityPub Create handler and optimize it Move networking calls out of the database transaction * Add "limited" visibility level masked as "private" in the API Unlike DMs, limited statuses are pushed into home feeds. The access control rules between direct and limited statuses is almost the same, except for counter and conversation logic * Ensure silent column is non-null, add spec * Ensure filters don't check silent mentions for blocks/mutes As those are "this person is also allowed to see" rather than "this person is involved", therefore does not warrant filtering * Clean up code * Use Status#active_mentions to limit returned mentions * Fix code style issues * Use Status#active_mentions in Notification And remove stream_entry eager-loading from Notification
39 lines
895 B
Ruby
39 lines
895 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ActivityPub::ReplyDistributionWorker
|
|
include Sidekiq::Worker
|
|
|
|
sidekiq_options queue: 'push'
|
|
|
|
def perform(status_id)
|
|
@status = Status.find(status_id)
|
|
@account = @status.thread&.account
|
|
|
|
return unless @account.present? && @status.distributable?
|
|
|
|
ActivityPub::DeliveryWorker.push_bulk(inboxes) do |inbox_url|
|
|
[signed_payload, @status.account_id, inbox_url]
|
|
end
|
|
rescue ActiveRecord::RecordNotFound
|
|
true
|
|
end
|
|
|
|
private
|
|
|
|
def inboxes
|
|
@inboxes ||= @account.followers.inboxes
|
|
end
|
|
|
|
def signed_payload
|
|
@signed_payload ||= Oj.dump(ActivityPub::LinkedDataSignature.new(payload).sign!(@status.account))
|
|
end
|
|
|
|
def payload
|
|
@payload ||= ActiveModelSerializers::SerializableResource.new(
|
|
@status,
|
|
serializer: ActivityPub::ActivitySerializer,
|
|
adapter: ActivityPub::Adapter
|
|
).as_json
|
|
end
|
|
end
|