Add group_key
attribute to NotificationSerializer
(#30776)
Co-authored-by: Renaud Chaput <renchap@gmail.com>
This commit is contained in:
parent
a0910cd49c
commit
7889e983fb
1 changed files with 5 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue