Fix serialization of added_to_collection notifications (#38612)
This commit is contained in:
parent
4ad54b279d
commit
66fdd3ae65
@ -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?
|
||||
|
||||
@ -48,6 +48,7 @@ class NotificationGroup < ActiveModelSerializers::Model
|
||||
|
||||
delegate :type,
|
||||
:target_status,
|
||||
:target_collection,
|
||||
:report,
|
||||
:account_relationship_severance_event,
|
||||
:account_warning,
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user