Correct some drift from upstream

This commit is contained in:
Mike Barnes 2025-09-17 20:43:39 +10:00
commit 2c4e689fe5

View file

@ -30,6 +30,7 @@ class Notification < ApplicationRecord
'FollowRequest' => :follow_request, 'FollowRequest' => :follow_request,
'Favourite' => :favourite, 'Favourite' => :favourite,
'Poll' => :poll, 'Poll' => :poll,
'Quote' => :quote,
}.freeze }.freeze
# Please update app/javascript/api_types/notification.ts if you change this # Please update app/javascript/api_types/notification.ts if you change this
@ -73,6 +74,12 @@ class Notification < ApplicationRecord
'admin.report': { 'admin.report': {
filterable: false, filterable: false,
}.freeze, }.freeze,
quote: {
filterable: true,
}.freeze,
quoted_update: {
filterable: false,
}.freeze,
}.freeze }.freeze
TYPES = PROPERTIES.keys.freeze TYPES = PROPERTIES.keys.freeze
@ -81,9 +88,11 @@ class Notification < ApplicationRecord
status: :status, status: :status,
reblog: [status: :reblog], reblog: [status: :reblog],
mention: [mention: :status], mention: [mention: :status],
quote: [quote: :status],
favourite: [favourite: :status], favourite: [favourite: :status],
poll: [poll: :status], poll: [poll: :status],
update: :status, update: :status,
quoted_update: :status,
'admin.report': [report: :target_account], 'admin.report': [report: :target_account],
}.freeze }.freeze
@ -102,12 +111,12 @@ class Notification < ApplicationRecord
belongs_to :account_relationship_severance_event, inverse_of: false belongs_to :account_relationship_severance_event, inverse_of: false
belongs_to :account_warning, inverse_of: false belongs_to :account_warning, inverse_of: false
belongs_to :generated_annual_report, inverse_of: false belongs_to :generated_annual_report, inverse_of: false
belongs_to :quote, inverse_of: :notification
end end
validates :type, inclusion: { in: TYPES } validates :type, inclusion: { in: TYPES }
scope :without_suspended, -> { joins(:from_account).merge(Account.without_suspended) } scope :without_suspended, -> { joins(:from_account).merge(Account.without_suspended) }
scope :by_group_key, ->(group_key) { group_key&.start_with?('ungrouped-') ? where(id: group_key.delete_prefix('ungrouped-')) : where(group_key: group_key) }
def type def type
@type ||= (super || LEGACY_TYPE_CLASS_MAP[activity_type]).to_sym @type ||= (super || LEGACY_TYPE_CLASS_MAP[activity_type]).to_sym
@ -115,7 +124,7 @@ class Notification < ApplicationRecord
def target_status def target_status
case type case type
when :status, :update when :status, :update, :quoted_update
status status
when :reblog when :reblog
status&.reblog status&.reblog
@ -123,6 +132,8 @@ class Notification < ApplicationRecord
favourite&.status favourite&.status
when :mention when :mention
mention&.status mention&.status
when :quote
quote&.status
when :poll when :poll
poll&.status poll&.status
end end
@ -165,7 +176,7 @@ class Notification < ApplicationRecord
cached_status = cached_statuses_by_id[notification.target_status.id] cached_status = cached_statuses_by_id[notification.target_status.id]
case notification.type case notification.type
when :status, :update when :status, :update, :quoted_update
notification.status = cached_status notification.status = cached_status
when :reblog when :reblog
notification.status.reblog = cached_status notification.status.reblog = cached_status
@ -175,6 +186,8 @@ class Notification < ApplicationRecord
notification.mention.status = cached_status notification.mention.status = cached_status
when :poll when :poll
notification.poll.status = cached_status notification.poll.status = cached_status
when :quote
notification.quote.status = cached_status
end end
end end
@ -193,7 +206,9 @@ class Notification < ApplicationRecord
return unless new_record? return unless new_record?
case activity_type case activity_type
when 'Status', 'Follow', 'Favourite', 'FollowRequest', 'Poll', 'Report' 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 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