Change grouped notifications API shape (take 2) (#31214)
This commit is contained in:
		@@ -0,0 +1,7 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class REST::DedupNotificationGroupSerializer < ActiveModel::Serializer
 | 
			
		||||
  has_many :accounts, serializer: REST::AccountSerializer
 | 
			
		||||
  has_many :statuses, serializer: REST::StatusSerializer
 | 
			
		||||
  has_many :notification_groups, serializer: REST::NotificationGroupSerializer
 | 
			
		||||
end
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user