Add quoted_update notification type (#35820)

This commit is contained in:
Claire 2025-08-25 17:44:18 +02:00 committed by GitHub
parent 7aba79ade9
commit f3a932d8a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 117 additions and 6 deletions

View file

@ -77,6 +77,9 @@ class Notification < ApplicationRecord
quote: {
filterable: true,
}.freeze,
quoted_update: {
filterable: false,
}.freeze,
}.freeze
TYPES = PROPERTIES.keys.freeze
@ -89,6 +92,7 @@ class Notification < ApplicationRecord
favourite: [favourite: :status],
poll: [poll: :status],
update: :status,
quoted_update: :status,
'admin.report': [report: :target_account],
}.freeze
@ -120,7 +124,7 @@ class Notification < ApplicationRecord
def target_status
case type
when :status, :update
when :status, :update, :quoted_update
status
when :reblog
status&.reblog
@ -172,7 +176,7 @@ class Notification < ApplicationRecord
cached_status = cached_statuses_by_id[notification.target_status.id]
case notification.type
when :status, :update
when :status, :update, :quoted_update
notification.status = cached_status
when :reblog
notification.status.reblog = cached_status
@ -202,7 +206,9 @@ class Notification < ApplicationRecord
return unless new_record?
case activity_type
when 'Status', 'Follow', 'Favourite', 'FollowRequest', 'Poll', 'Report', 'Quote'
when 'Status'
self.from_account_id = type == :quoted_update ? activity&.quote&.quoted_account_id : activity&.account_id
when 'Follow', 'Favourite', 'FollowRequest', 'Poll', 'Report', 'Quote'
self.from_account_id = activity&.account_id
when 'Mention'
self.from_account_id = activity&.status&.account_id