Fix moderator account being exposed in account moderation notification (#30082)
This commit is contained in:
parent
5201882a23
commit
e845594878
|
@ -184,13 +184,13 @@ class Notification < ApplicationRecord
|
||||||
return unless new_record?
|
return unless new_record?
|
||||||
|
|
||||||
case activity_type
|
case activity_type
|
||||||
when 'Status', 'Follow', 'Favourite', 'FollowRequest', 'Poll', 'Report', 'AccountWarning'
|
when 'Status', 'Follow', 'Favourite', 'FollowRequest', 'Poll', 'Report'
|
||||||
self.from_account_id = activity&.account_id
|
self.from_account_id = activity&.account_id
|
||||||
when 'Mention'
|
when 'Mention'
|
||||||
self.from_account_id = activity&.status&.account_id
|
self.from_account_id = activity&.status&.account_id
|
||||||
when 'Account'
|
when 'Account'
|
||||||
self.from_account_id = activity&.id
|
self.from_account_id = activity&.id
|
||||||
when 'AccountRelationshipSeveranceEvent'
|
when 'AccountRelationshipSeveranceEvent', 'AccountWarning'
|
||||||
# These do not really have an originating account, but this is mandatory
|
# These do not really have an originating account, but this is mandatory
|
||||||
# in the data model, and the recipient's account will by definition
|
# in the data model, and the recipient's account will by definition
|
||||||
# always exist
|
# always exist
|
||||||
|
|
|
@ -138,6 +138,17 @@ RSpec.describe Notification do
|
||||||
expect(notification.account).to eq(account)
|
expect(notification.account).to eq(account)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when activity_type is an AccountWarning' do
|
||||||
|
it 'sets the notification from_account to the recipient of the notification' do
|
||||||
|
account = Fabricate(:account)
|
||||||
|
account_warning = Fabricate(:account_warning, target_account: account)
|
||||||
|
|
||||||
|
notification = Fabricate.build(:notification, activity_type: 'AccountWarning', activity: account_warning, account: account)
|
||||||
|
|
||||||
|
expect(notification.from_account).to eq(account)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.preload_cache_collection_target_statuses' do
|
describe '.preload_cache_collection_target_statuses' do
|
||||||
|
|
Loading…
Reference in New Issue