mirror of https://github.com/mastodon/mastodon
Change grouped notifications API shape (take 2) (#31214)
parent
288961bbb9
commit
549ab089ee
@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class GroupedNotificationsPresenter < ActiveModelSerializers::Model
|
||||
def initialize(grouped_notifications)
|
||||
super()
|
||||
|
||||
@grouped_notifications = grouped_notifications
|
||||
end
|
||||
|
||||
def notification_groups
|
||||
@grouped_notifications
|
||||
end
|
||||
|
||||
def statuses
|
||||
@grouped_notifications.filter_map(&:target_status).uniq(&:id)
|
||||
end
|
||||
|
||||
def accounts
|
||||
@grouped_notifications.flat_map(&:sample_accounts).uniq(&:id)
|
||||
end
|
||||
end
|
@ -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
|
Loading…
Reference in New Issue