diff --git a/app/models/notification.rb b/app/models/notification.rb index 19b057108e..a78db0281c 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -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? diff --git a/app/models/notification_group.rb b/app/models/notification_group.rb index bf790bf7cd..1d43536443 100644 --- a/app/models/notification_group.rb +++ b/app/models/notification_group.rb @@ -48,6 +48,7 @@ class NotificationGroup < ActiveModelSerializers::Model delegate :type, :target_status, + :target_collection, :report, :account_relationship_severance_event, :account_warning, diff --git a/app/serializers/rest/notification_group_serializer.rb b/app/serializers/rest/notification_group_serializer.rb index 6089a2446a..3f95d78fc4 100644 --- a/app/serializers/rest/notification_group_serializer.rb +++ b/app/serializers/rest/notification_group_serializer.rb @@ -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) diff --git a/app/serializers/rest/notification_serializer.rb b/app/serializers/rest/notification_serializer.rb index ab1626cf3b..f337aab943 100644 --- a/app/serializers/rest/notification_serializer.rb +++ b/app/serializers/rest/notification_serializer.rb @@ -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