This commit is contained in:
Matt Jankowski 2026-03-27 09:22:03 +00:00 committed by GitHub
commit d34ae71fe9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 19 additions and 9 deletions

View File

@ -14,7 +14,7 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController
@account = current_account
UpdateAccountService.new.call(@account, account_params, raise_error: true)
current_user.update(user_params) if user_params
ActivityPub::UpdateDistributionWorker.perform_in(ActivityPub::UpdateDistributionWorker::DEBOUNCE_DELAY, @account.id)
ActivityPub::UpdateDistributionWorker.distribute(@account)
render json: @account, serializer: REST::CredentialAccountSerializer
rescue ActiveRecord::RecordInvalid => e
render json: ValidationErrorFormatter.new(e).as_json, status: 422

View File

@ -7,7 +7,7 @@ class Api::V1::Profile::AvatarsController < Api::BaseController
def destroy
@account = current_account
UpdateAccountService.new.call(@account, { avatar: nil }, raise_error: true)
ActivityPub::UpdateDistributionWorker.perform_in(ActivityPub::UpdateDistributionWorker::DEBOUNCE_DELAY, @account.id)
ActivityPub::UpdateDistributionWorker.distribute(@account)
render json: @account, serializer: REST::CredentialAccountSerializer
end
end

View File

@ -7,7 +7,7 @@ class Api::V1::Profile::HeadersController < Api::BaseController
def destroy
@account = current_account
UpdateAccountService.new.call(@account, { header: nil }, raise_error: true)
ActivityPub::UpdateDistributionWorker.perform_in(ActivityPub::UpdateDistributionWorker::DEBOUNCE_DELAY, @account.id)
ActivityPub::UpdateDistributionWorker.distribute(@account)
render json: @account, serializer: REST::CredentialAccountSerializer
end
end

View File

@ -8,7 +8,7 @@ module Settings
def destroy
if valid_picture?
if UpdateAccountService.new.call(@account, { @picture => nil, "#{@picture}_remote_url" => '' })
ActivityPub::UpdateDistributionWorker.perform_in(ActivityPub::UpdateDistributionWorker::DEBOUNCE_DELAY, @account.id)
ActivityPub::UpdateDistributionWorker.distribute(@account)
redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg'), status: 303
else
redirect_to settings_profile_path

View File

@ -9,7 +9,7 @@ class Settings::PrivacyController < Settings::BaseController
def update
if UpdateAccountService.new.call(@account, account_params.except(:settings))
current_user.update!(settings_attributes: account_params[:settings])
ActivityPub::UpdateDistributionWorker.perform_in(ActivityPub::UpdateDistributionWorker::DEBOUNCE_DELAY, @account.id)
ActivityPub::UpdateDistributionWorker.distribute(@account)
redirect_to settings_privacy_path, notice: I18n.t('generic.changes_saved_msg')
else
render :show

View File

@ -9,7 +9,7 @@ class Settings::ProfilesController < Settings::BaseController
def update
if UpdateAccountService.new.call(@account, account_params)
ActivityPub::UpdateDistributionWorker.perform_in(ActivityPub::UpdateDistributionWorker::DEBOUNCE_DELAY, @account.id)
ActivityPub::UpdateDistributionWorker.distribute(@account)
redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg')
else
@account.build_fields

View File

@ -8,7 +8,7 @@ class Settings::VerificationsController < Settings::BaseController
def update
if UpdateAccountService.new.call(@account, account_params)
ActivityPub::UpdateDistributionWorker.perform_in(ActivityPub::UpdateDistributionWorker::DEBOUNCE_DELAY, @account.id)
ActivityPub::UpdateDistributionWorker.distribute(@account)
redirect_to settings_verification_path, notice: I18n.t('generic.changes_saved_msg')
else
render :show

View File

@ -363,7 +363,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
end
increment_voters_count! unless already_voted
ActivityPub::DistributePollUpdateWorker.perform_in(3.minutes, replied_to_status.id) unless replied_to_status.preloadable_poll.hide_totals?
ActivityPub::DistributePollUpdateWorker.distribute(replied_to_status) unless replied_to_status.preloadable_poll.hide_totals?
end
def resolve_thread(status)

View File

@ -45,7 +45,7 @@ class VoteService < BaseService
def distribute_poll!
return if @poll.hide_totals?
ActivityPub::DistributePollUpdateWorker.perform_in(3.minutes, @poll.status.id)
ActivityPub::DistributePollUpdateWorker.distribute(@poll.status)
end
def queue_final_poll_check!

View File

@ -4,6 +4,8 @@ class ActivityPub::DistributePollUpdateWorker
include Sidekiq::Worker
include Payloadable
PROCESSING_DELAY = 3.minutes
sidekiq_options queue: 'push', lock: :until_executed, retry: 0
def perform(status_id)
@ -21,6 +23,10 @@ class ActivityPub::DistributePollUpdateWorker
true
end
def self.distribute(status)
perform_in(PROCESSING_DELAY, status.id)
end
private
def relayable?

View File

@ -16,6 +16,10 @@ class ActivityPub::UpdateDistributionWorker < ActivityPub::RawDistributionWorker
true
end
def self.distribute(account)
perform_in(DEBOUNCE_DELAY, account.id)
end
protected
def inboxes