Add group_key attribute to NotificationSerializer (#30776)

Co-authored-by: Renaud Chaput <renchap@gmail.com>
This commit is contained in:
Claire 2024-06-20 13:05:25 +02:00 committed by GitHub
parent a0910cd49c
commit 7889e983fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
class REST::NotificationSerializer < ActiveModel::Serializer
attributes :id, :type, :created_at
attributes :id, :type, :created_at, :group_key
belongs_to :from_account, key: :account, serializer: REST::AccountSerializer
belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer
@ -13,6 +13,10 @@ class REST::NotificationSerializer < ActiveModel::Serializer
object.id.to_s
end
def group_key
object.group_key || "ungrouped-#{object.id}"
end
def status_type?
[:favourite, :reblog, :status, :mention, :poll, :update].include?(object.type)
end