Fix serialization of added_to_collection notifications (#38612)

This commit is contained in:
Claire 2026-04-08 18:40:51 +02:00 committed by GitHub
parent 4ad54b279d
commit 66fdd3ae65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 2 deletions

View File

@ -147,6 +147,15 @@ class Notification < ApplicationRecord
end
end
def target_collection
case type
when :added_to_collection
collection_item&.collection
when :collection_update
collection
end
end
class << self
def browserable(types: [], exclude_types: [], from_account_id: nil, include_filtered: false)
requested_types = if types.empty?

View File

@ -48,6 +48,7 @@ class NotificationGroup < ActiveModelSerializers::Model
delegate :type,
:target_status,
:target_collection,
:report,
:account_relationship_severance_event,
:account_warning,

View File

@ -14,7 +14,7 @@ class REST::NotificationGroupSerializer < ActiveModel::Serializer
belongs_to :account_relationship_severance_event, key: :event, if: :relationship_severance_event?, serializer: REST::AccountRelationshipSeveranceEventSerializer
belongs_to :account_warning, key: :moderation_warning, if: :moderation_warning_event?, serializer: REST::AccountWarningSerializer
belongs_to :generated_annual_report, key: :annual_report, if: :annual_report_event?, serializer: REST::AnnualReportEventSerializer
belongs_to :collection, if: :collection_type?, serializer: REST::CollectionSerializer
belongs_to :target_collection, key: :collection, if: :collection_type?, serializer: REST::CollectionSerializer
def sample_account_ids
object.sample_accounts.pluck(:id).map(&:to_s)

View File

@ -11,7 +11,7 @@ class REST::NotificationSerializer < ActiveModel::Serializer
belongs_to :report, if: :report_type?, serializer: REST::ReportSerializer
belongs_to :account_relationship_severance_event, key: :event, if: :relationship_severance_event?, serializer: REST::AccountRelationshipSeveranceEventSerializer
belongs_to :account_warning, key: :moderation_warning, if: :moderation_warning_event?, serializer: REST::AccountWarningSerializer
belongs_to :collection, if: :collection_type?, serializer: REST::CollectionSerializer
belongs_to :target_collection, key: :collection, if: :collection_type?, serializer: REST::CollectionSerializer
def id
object.id.to_s