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,
'Favourite' => :favourite,
'Poll' => :poll,
'Quote' => :quote,
}.freeze
# Please update app/javascript/api_types/notification.ts if you change this
@ -73,6 +74,12 @@ class Notification < ApplicationRecord
'admin.report': {
filterable: false,
}.freeze,
quote: {
filterable: true,
}.freeze,
quoted_update: {
filterable: false,
}.freeze,
}.freeze
TYPES = PROPERTIES.keys.freeze
@ -81,9 +88,11 @@ class Notification < ApplicationRecord
status: :status,
reblog: [status: :reblog],
mention: [mention: :status],
quote: [quote: :status],
favourite: [favourite: :status],
poll: [poll: :status],
update: :status,
quoted_update: :status,
'admin.report': [report: :target_account],
}.freeze
@ -102,12 +111,12 @@ class Notification < ApplicationRecord
belongs_to :account_relationship_severance_event, inverse_of: false
belongs_to :account_warning, inverse_of: false
belongs_to :generated_annual_report, inverse_of: false
belongs_to :quote, inverse_of: :notification
end
validates :type, inclusion: { in: TYPES }
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
@type ||= (super || LEGACY_TYPE_CLASS_MAP[activity_type]).to_sym
@ -115,7 +124,7 @@ class Notification < ApplicationRecord
def target_status
case type
when :status, :update
when :status, :update, :quoted_update
status
when :reblog
status&.reblog
@ -123,6 +132,8 @@ class Notification < ApplicationRecord
favourite&.status
when :mention
mention&.status
when :quote
quote&.status
when :poll
poll&.status
end
@ -165,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
@ -175,6 +186,8 @@ class Notification < ApplicationRecord
notification.mention.status = cached_status
when :poll
notification.poll.status = cached_status
when :quote
notification.quote.status = cached_status
end
end
@ -193,7 +206,9 @@ class Notification < ApplicationRecord
return unless new_record?
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
when 'Mention'
self.from_account_id = activity&.status&.account_id