Add missing `moderation_warning` notification support to grouped notifications API (#30576)

pull/30577/head
Claire 2024-06-06 16:12:06 +02:00 committed by GitHub
parent 5652ca6135
commit 1ffc293b86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -11,6 +11,7 @@ class REST::NotificationGroupSerializer < ActiveModel::Serializer
belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer
belongs_to :report, if: :report_type?, serializer: REST::ReportSerializer 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_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
def status_type? def status_type?
[:favourite, :reblog, :status, :mention, :poll, :update].include?(object.type) [:favourite, :reblog, :status, :mention, :poll, :update].include?(object.type)
@ -24,6 +25,10 @@ class REST::NotificationGroupSerializer < ActiveModel::Serializer
object.type == :severed_relationships object.type == :severed_relationships
end end
def moderation_warning_event?
object.type == :moderation_warning
end
def page_min_id def page_min_id
range = instance_options[:group_metadata][object.group_key] range = instance_options[:group_metadata][object.group_key]
range.present? ? range[:min_id].to_s : object.notification.id.to_s range.present? ? range[:min_id].to_s : object.notification.id.to_s