mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-08 10:50:58 +00:00
Use consistent naming
This commit is contained in:
parent
dae6cd9d51
commit
f02b006151
|
@ -26,11 +26,13 @@ class ActivityPub::Activity::Update < ActivityPub::Activity
|
||||||
def update_status
|
def update_status
|
||||||
return reject_payload! if non_matching_uri_hosts?(@account.uri, object_uri)
|
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)
|
@status = Status.find_by(uri: object_uri, account_id: status_account_id)
|
||||||
return if @status.nil?
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
||||||
include Redisable
|
include Redisable
|
||||||
include Lockable
|
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?
|
raise ArgumentError, 'Status has unsaved changes' if status.changed?
|
||||||
|
|
||||||
@activity_json = activity_json
|
@activity_json = activity_json
|
||||||
|
@ -17,7 +17,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
||||||
@media_attachments_changed = false
|
@media_attachments_changed = false
|
||||||
@poll_changed = false
|
@poll_changed = false
|
||||||
@request_id = request_id
|
@request_id = request_id
|
||||||
@editor_id = editor_id
|
@activity_account_id = activity_account_id
|
||||||
|
|
||||||
# Only native types can be updated at the moment
|
# Only native types can be updated at the moment
|
||||||
return @status if !expected_type? || already_updated_more_recently?
|
return @status if !expected_type? || already_updated_more_recently?
|
||||||
|
@ -252,8 +252,11 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
||||||
return unless significant_changes?
|
return unless significant_changes?
|
||||||
|
|
||||||
@previous_edit&.save!
|
@previous_edit&.save!
|
||||||
account_id = @editor_id || @account.id
|
@status.snapshot!(account_id: editor_account_id, rate_limit: false)
|
||||||
@status.snapshot!(account_id: account_id, rate_limit: false)
|
end
|
||||||
|
|
||||||
|
def editor_account_id
|
||||||
|
@activity_account_id || @account.id
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip_download?
|
def skip_download?
|
||||||
|
|
|
@ -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'
|
expect(status.reload.edited_at.to_s).to eq '2021-09-08 22:39:25 UTC'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with an editor_id' do
|
context 'with an activity_account_id' do
|
||||||
let(:editor) { Fabricate(:account) }
|
let(:activity_account) { Fabricate(:account) }
|
||||||
|
|
||||||
it 'creates edits with the right editor' do
|
it 'creates edits with the right editor' do
|
||||||
allow(DistributionWorker).to receive(:perform_async)
|
allow(DistributionWorker).to receive(:perform_async)
|
||||||
subject.call(status, json, json, editor_id: editor.id)
|
subject.call(status, json, json, activity_account_id: activity_account.id)
|
||||||
expect(status.edits.reload.last.account_id).to eq editor.id
|
expect(status.edits.reload.last.account_id).to eq activity_account.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without an editor_id' do
|
context 'without an activity_account_id' do
|
||||||
it 'creates edits with the right editor' do
|
it 'creates edits with the right editor' do
|
||||||
allow(DistributionWorker).to receive(:perform_async)
|
allow(DistributionWorker).to receive(:perform_async)
|
||||||
subject.call(status, json, json)
|
subject.call(status, json, json)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user