mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 10:36:32 +08:00
ef0fe51e05
The payload when receiving a notification webhook is pointless without knowing which user the notification is for. This fix adds the user_id to the notification serializer so that when you receive a notification webhook you can properly identify which user the notification is for. See https://meta.discourse.org/t/getting-the-target-user-for-notification-webhook-events/129052?u=blake for more details.
42 lines
742 B
Ruby
42 lines
742 B
Ruby
# frozen_string_literal: true
|
|
|
|
class NotificationSerializer < ApplicationSerializer
|
|
|
|
attributes :id,
|
|
:user_id,
|
|
:notification_type,
|
|
:read,
|
|
:created_at,
|
|
:post_number,
|
|
:topic_id,
|
|
:fancy_title,
|
|
:slug,
|
|
:data,
|
|
:is_warning
|
|
|
|
def slug
|
|
Slug.for(object.topic.title) if object.topic.present?
|
|
end
|
|
|
|
def is_warning
|
|
object.topic.present? && object.topic.subtype == TopicSubtype.moderator_warning
|
|
end
|
|
|
|
def include_fancy_title?
|
|
object.topic&.fancy_title
|
|
end
|
|
|
|
def fancy_title
|
|
object.topic.fancy_title
|
|
end
|
|
|
|
def include_is_warning?
|
|
is_warning
|
|
end
|
|
|
|
def data
|
|
object.data_hash
|
|
end
|
|
|
|
end
|