mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 05:13:44 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
41 lines
719 B
Ruby
41 lines
719 B
Ruby
# frozen_string_literal: true
|
|
|
|
class NotificationSerializer < ApplicationSerializer
|
|
|
|
attributes :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
|