1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Use consistent naming

This commit is contained in:
Angus McLeod 2023-10-24 15:43:41 +08:00
parent dae6cd9d51
commit f02b006151
3 changed files with 17 additions and 12 deletions

View file

@ -26,11 +26,13 @@ class ActivityPub::Activity::Update < ActivityPub::Activity
def update_status
return reject_payload! if non_matching_uri_hosts?(@account.uri, object_uri)
editor_id = @account.id
status_account_id = object_actor ? object_actor.id : editor_id
@status = Status.find_by(uri: object_uri, account_id: status_account_id)
return if @status.nil?
ActivityPub::ProcessStatusUpdateService.new.call(@status, @json, @object, request_id: @options[:request_id], editor_id: editor_id)
ActivityPub::ProcessStatusUpdateService.new.call(@status, @json, @object, request_id: @options[:request_id], activity_account_id: @account.id)
end
def status_account_id
object_actor ? object_actor.id : @account.id
end
end

View file

@ -5,7 +5,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
include Redisable
include Lockable
def call(status, activity_json, object_json, request_id: nil, editor_id: nil)
def call(status, activity_json, object_json, request_id: nil, activity_account_id: nil)
raise ArgumentError, 'Status has unsaved changes' if status.changed?
@activity_json = activity_json
@ -17,7 +17,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
@media_attachments_changed = false
@poll_changed = false
@request_id = request_id
@editor_id = editor_id
@activity_account_id = activity_account_id
# Only native types can be updated at the moment
return @status if !expected_type? || already_updated_more_recently?
@ -252,8 +252,11 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
return unless significant_changes?
@previous_edit&.save!
account_id = @editor_id || @account.id
@status.snapshot!(account_id: account_id, rate_limit: false)
@status.snapshot!(account_id: editor_account_id, rate_limit: false)
end
def editor_account_id
@activity_account_id || @account.id
end
def skip_download?

View file

@ -463,17 +463,17 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
expect(status.reload.edited_at.to_s).to eq '2021-09-08 22:39:25 UTC'
end
context 'with an editor_id' do
let(:editor) { Fabricate(:account) }
context 'with an activity_account_id' do
let(:activity_account) { Fabricate(:account) }
it 'creates edits with the right editor' do
allow(DistributionWorker).to receive(:perform_async)
subject.call(status, json, json, editor_id: editor.id)
expect(status.edits.reload.last.account_id).to eq editor.id
subject.call(status, json, json, activity_account_id: activity_account.id)
expect(status.edits.reload.last.account_id).to eq activity_account.id
end
end
context 'without an editor_id' do
context 'without an activity_account_id' do
it 'creates edits with the right editor' do
allow(DistributionWorker).to receive(:perform_async)
subject.call(status, json, json)