0
0
Fork 0

Change grouped notifications API shape (take 2) (#31214)

This commit is contained in:
Claire 2024-07-31 12:50:13 +02:00 committed by GitHub
parent 288961bbb9
commit 549ab089ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 70 additions and 20 deletions

View file

@ -8,12 +8,20 @@ class REST::NotificationGroupSerializer < ActiveModel::Serializer
attribute :page_max_id, if: :paginated?
attribute :latest_page_notification_at, if: :paginated?
has_many :sample_accounts, serializer: REST::AccountSerializer
belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer
attribute :sample_account_ids
attribute :status_id, if: :status_type?
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
def sample_account_ids
object.sample_accounts.pluck(:id).map(&:to_s)
end
def status_id
object.target_status&.id&.to_s
end
def status_type?
[:favourite, :reblog, :status, :mention, :poll, :update].include?(object.type)
end