/
notification_serializer.rb
58 lines (47 loc) · 1.13 KB
/
notification_serializer.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# frozen_string_literal: true
class NotificationSerializer < ApplicationSerializer
attributes :id,
:user_id,
:external_id,
:notification_type,
:read,
:high_priority,
:created_at,
:post_number,
:topic_id,
:fancy_title,
:slug,
:data,
:is_warning,
:acting_user_avatar_template
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
def external_id
object.user&.single_sign_on_record&.external_id
end
def include_external_id?
SiteSetting.enable_discourse_connect
end
def acting_user_avatar_template
object.acting_user.avatar_template_url
end
def include_acting_user_avatar_template?
object.acting_user.present?
end
end