Class: TopicViewSerializer
Class Method Summary
collapse
Instance Method Summary
collapse
#add_resource_preload_list, #admin?, #age_words, all_connectors, #allow_plugins?, #allow_third_party_plugins?, #application_logo_dark_url, #application_logo_url, #authentication_data, #body_classes, #build_plugin_html, #can_sign_up?, #category_badge, #client_side_setup_data, #crawlable_meta_data, #crawler_layout?, #current_homepage, #customization_disabled?, #dark_color_scheme?, #dark_scheme_id, #discourse_color_scheme_stylesheets, #discourse_config_environment, #discourse_csrf_tags, #discourse_preload_color_scheme_stylesheets, #discourse_stylesheet_link_tag, #discourse_stylesheet_preload_tag, #discourse_theme_color_meta_tags, #escape_unicode, extra_body_classes, #format_topic_title, #ga_universal_json, #get_absolute_image_url, #google_tag_manager_json, #google_tag_manager_nonce_placeholder, #google_universal_analytics_json, #gsub_emoji_to_unicode, #guardian, #html_classes, #html_lang, #include_crawler_content?, #include_ios_native_app_banner?, #include_splash_screen?, #ios_app_argument, #ios_device?, #is_brotli_req?, #is_gzip_req?, #loading_admin?, #login_path, #manifest_url, #mobile_device?, #mobile_view?, #moderator?, #modern_mobile_device?, #normalized_safe_mode, #preload_script, #preload_script_url, #preloaded_json, #render_sitelinks_search_tag, #replace_plugin_html, #rss_creator, #rtl?, #scheme_id, #script_asset_path, #server_plugin_outlet, #shared_session_key, #short_date, #staff?, #stylesheet_manager, #text_size_class, #theme_id, #theme_js_lookup, #theme_lookup, #theme_translations_lookup, #topic_featured_link_domain, #waving_hand_url, #with_format
Methods included from GlobalPath
#cdn_path, #cdn_relative_path, #full_cdn_url, #path, #upload_cdn_path
#faq_path, #privacy_policy_url, #tos_url
#canonical_link_tag
#clear_current_user, #current_user, has_auth_cookie?, #is_api?, #is_user_api?, #log_off_user, #log_on_user, lookup_from_env, #refresh_session
#include_tags?, included, #tags, #tags_descriptions, #topic
#include_related_messages?, #include_suggested_group_name?, #include_suggested_topics?, included, #related_messages, #suggested_group_name, #suggested_topics
#include_gaps?, #include_stream?, #include_timeline_lookup?, included, #post_stream, #posts, #timeline_lookup
expire_cache_fragment!, fragment_cache
#include!
Class Method Details
.attributes_from_topic(*list) ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'app/serializers/topic_view_serializer.rb', line 9
def self.attributes_from_topic(*list)
[list].flatten.each do |attribute|
attributes(attribute)
class_eval %{def #{attribute}
object.topic.#{attribute}
end}
end
end
|
Instance Method Details
#actions_summary ⇒ Object
178
179
180
|
# File 'app/serializers/topic_view_serializer.rb', line 178
def actions_summary
object.actions_summary
end
|
#bookmarked ⇒ Object
198
199
200
|
# File 'app/serializers/topic_view_serializer.rb', line 198
def bookmarked
object.has_bookmarks?
end
|
#bookmarks ⇒ Object
202
203
204
|
# File 'app/serializers/topic_view_serializer.rb', line 202
def bookmarks
object.bookmarks
end
|
#chunk_size ⇒ Object
97
98
99
|
# File 'app/serializers/topic_view_serializer.rb', line 97
def chunk_size
object.chunk_size
end
|
#current_post_number ⇒ Object
142
143
144
|
# File 'app/serializers/topic_view_serializer.rb', line 142
def current_post_number
object.current_post_number
end
|
#deleted_by ⇒ Object
133
134
135
|
# File 'app/serializers/topic_view_serializer.rb', line 133
def deleted_by
BasicUserSerializer.new(object.topic.deleted_by, root: false).as_json
end
|
#destination_category_id ⇒ Object
246
247
248
|
# File 'app/serializers/topic_view_serializer.rb', line 246
def destination_category_id
object.topic.shared_draft.category_id
end
|
#details ⇒ Object
89
90
91
|
# File 'app/serializers/topic_view_serializer.rb', line 89
def details
object
end
|
#draft ⇒ Object
113
114
115
|
# File 'app/serializers/topic_view_serializer.rb', line 113
def draft
object.draft
end
|
#draft_key ⇒ Object
117
118
119
|
# File 'app/serializers/topic_view_serializer.rb', line 117
def draft_key
object.draft_key
end
|
#draft_sequence ⇒ Object
121
122
123
|
# File 'app/serializers/topic_view_serializer.rb', line 121
def draft_sequence
object.draft_sequence
end
|
#expandable_first_post ⇒ Object
190
191
192
|
# File 'app/serializers/topic_view_serializer.rb', line 190
def expandable_first_post
true
end
|
#has_deleted ⇒ Object
182
183
184
|
# File 'app/serializers/topic_view_serializer.rb', line 182
def has_deleted
object.has_deleted?
end
|
#has_topic_user? ⇒ Boolean
Also known as:
include_last_read_post_id?, include_last_read_post_number?, include_posted?
138
139
140
|
# File 'app/serializers/topic_view_serializer.rb', line 138
def has_topic_user?
object.topic_user.present?
end
|
#highest_post_number ⇒ Object
150
151
152
|
# File 'app/serializers/topic_view_serializer.rb', line 150
def highest_post_number
object.highest_post_number
end
|
#include_current_post_number? ⇒ Boolean
146
147
148
|
# File 'app/serializers/topic_view_serializer.rb', line 146
def include_current_post_number?
object.current_post_number.present?
end
|
#include_destination_category_id? ⇒ Boolean
Also known as:
include_is_shared_draft?
250
251
252
253
|
# File 'app/serializers/topic_view_serializer.rb', line 250
def include_destination_category_id?
scope.can_see_shared_draft? && SiteSetting.shared_drafts_enabled? &&
object.topic.shared_draft.present?
end
|
#include_expandable_first_post? ⇒ Boolean
194
195
196
|
# File 'app/serializers/topic_view_serializer.rb', line 194
def include_expandable_first_post?
object.topic.expandable_first_post?
end
|
#include_external_id? ⇒ Boolean
109
110
111
|
# File 'app/serializers/topic_view_serializer.rb', line 109
def include_external_id?
external_id
end
|
#include_featured_link? ⇒ Boolean
218
219
220
|
# File 'app/serializers/topic_view_serializer.rb', line 218
def include_featured_link?
SiteSetting.topic_featured_link_enabled
end
|
#include_featured_link_root_domain? ⇒ Boolean
222
223
224
|
# File 'app/serializers/topic_view_serializer.rb', line 222
def include_featured_link_root_domain?
SiteSetting.topic_featured_link_enabled && object.topic.featured_link
end
|
#include_has_deleted? ⇒ Boolean
186
187
188
|
# File 'app/serializers/topic_view_serializer.rb', line 186
def include_has_deleted?
object.guardian.can_see_deleted_posts?
end
|
#include_is_warning? ⇒ Boolean
105
106
107
|
# File 'app/serializers/topic_view_serializer.rb', line 105
def include_is_warning?
is_warning
end
|
#include_message_archived? ⇒ Boolean
125
126
127
|
# File 'app/serializers/topic_view_serializer.rb', line 125
def include_message_archived?
object.personal_message
end
|
#include_pending_posts? ⇒ Boolean
261
262
263
|
# File 'app/serializers/topic_view_serializer.rb', line 261
def include_pending_posts?
scope.authenticated? && object.queued_posts_enabled?
end
|
#include_pm_with_non_human_user? ⇒ Boolean
234
235
236
|
# File 'app/serializers/topic_view_serializer.rb', line 234
def include_pm_with_non_human_user?
object.personal_message
end
|
#include_published_page? ⇒ Boolean
294
295
296
297
|
# File 'app/serializers/topic_view_serializer.rb', line 294
def include_published_page?
SiteSetting.enable_page_publishing? && scope.is_staff? && object.published_page.present? &&
!SiteSetting.secure_uploads
end
|
#include_queued_posts_count? ⇒ Boolean
269
270
271
|
# File 'app/serializers/topic_view_serializer.rb', line 269
def include_queued_posts_count?
scope.is_staff? && object.queued_posts_enabled?
end
|
#include_requested_group_name? ⇒ Boolean
290
291
292
|
# File 'app/serializers/topic_view_serializer.rb', line 290
def include_requested_group_name?
object.personal_message && object.topic.custom_fields["requested_group_id"]
end
|
#include_unicode_title? ⇒ Boolean
226
227
228
|
# File 'app/serializers/topic_view_serializer.rb', line 226
def include_unicode_title?
object.topic.title.match?(/:[\w\-+]+:/)
end
|
#include_user_last_posted_at? ⇒ Boolean
308
309
310
|
# File 'app/serializers/topic_view_serializer.rb', line 308
def include_user_last_posted_at?
has_topic_user? && object.topic.slow_mode_seconds.to_i > 0
end
|
#is_shared_draft ⇒ Object
255
256
257
|
# File 'app/serializers/topic_view_serializer.rb', line 255
def is_shared_draft
include_destination_category_id?
end
|
#is_warning ⇒ Object
101
102
103
|
# File 'app/serializers/topic_view_serializer.rb', line 101
def is_warning
object.personal_message && object.topic.subtype == TopicSubtype.moderator_warning
end
|
#last_read_post_id ⇒ Object
154
155
156
157
|
# File 'app/serializers/topic_view_serializer.rb', line 154
def last_read_post_id
return nil unless last_read_post_number
object.filtered_post_id(last_read_post_number)
end
|
#last_read_post_number ⇒ Object
160
161
162
|
# File 'app/serializers/topic_view_serializer.rb', line 160
def last_read_post_number
@last_read_post_number ||= object.topic_user.last_read_post_number
end
|
#message_archived ⇒ Object
129
130
131
|
# File 'app/serializers/topic_view_serializer.rb', line 129
def message_archived
object.topic.message_archived?(scope.user)
end
|
#message_bus_last_id ⇒ Object
93
94
95
|
# File 'app/serializers/topic_view_serializer.rb', line 93
def message_bus_last_id
object.message_bus_last_id
end
|
#participant_count ⇒ Object
242
243
244
|
# File 'app/serializers/topic_view_serializer.rb', line 242
def participant_count
object.participant_count
end
|
#pinned ⇒ Object
170
171
172
|
# File 'app/serializers/topic_view_serializer.rb', line 170
def pinned
PinnedCheck.pinned?(object.topic, object.topic_user)
end
|
#pm_with_non_human_user ⇒ Object
238
239
240
|
# File 'app/serializers/topic_view_serializer.rb', line 238
def pm_with_non_human_user
object.topic.pm_with_non_human_user?
end
|
#posted ⇒ Object
165
166
167
|
# File 'app/serializers/topic_view_serializer.rb', line 165
def posted
object.topic_user.posted?
end
|
#queued_posts_count ⇒ Object
265
266
267
|
# File 'app/serializers/topic_view_serializer.rb', line 265
def queued_posts_count
object.queued_posts_count
end
|
#requested_group_name ⇒ Object
277
278
279
280
281
282
283
284
285
286
287
288
|
# File 'app/serializers/topic_view_serializer.rb', line 277
def requested_group_name
Group
.joins(:group_users)
.where(
id: object.topic.custom_fields["requested_group_id"].to_i,
group_users: {
user_id: scope.user.id,
owner: true,
},
)
.pick(:name)
end
|
#show_read_indicator ⇒ Object
273
274
275
|
# File 'app/serializers/topic_view_serializer.rb', line 273
def show_read_indicator
object.show_read_indicator?
end
|
#slow_mode_enabled_until ⇒ Object
312
313
314
|
# File 'app/serializers/topic_view_serializer.rb', line 312
def slow_mode_enabled_until
object.topic.slow_mode_topic_timer&.execute_at
end
|
#summarizable ⇒ Object
316
317
318
|
# File 'app/serializers/topic_view_serializer.rb', line 316
def summarizable
object.summarizable?
end
|
#thumbnails ⇒ Object
299
300
301
302
|
# File 'app/serializers/topic_view_serializer.rb', line 299
def thumbnails
= ThemeModifierHelper.new(request: scope.request).topic_thumbnail_sizes
object.topic.thumbnail_info(enqueue_if_missing: true, extra_sizes: )
end
|
#topic_timer ⇒ Object
206
207
208
209
210
211
212
213
214
215
216
|
# File 'app/serializers/topic_view_serializer.rb', line 206
def topic_timer
topic_timer = object.topic.public_topic_timer
return nil if topic_timer.blank?
if topic_timer.publishing_to_category?
return nil if !scope.can_see_category?(Category.find_by(id: topic_timer.category_id))
end
TopicTimerSerializer.new(object.topic.public_topic_timer, root: false)
end
|
#unicode_title ⇒ Object
230
231
232
|
# File 'app/serializers/topic_view_serializer.rb', line 230
def unicode_title
Emoji.gsub_emoji_to_unicode(object.topic.title)
end
|
#unpinned ⇒ Object
174
175
176
|
# File 'app/serializers/topic_view_serializer.rb', line 174
def unpinned
PinnedCheck.unpinned?(object.topic, object.topic_user)
end
|
#user_last_posted_at ⇒ Object
304
305
306
|
# File 'app/serializers/topic_view_serializer.rb', line 304
def user_last_posted_at
object.topic_user.last_posted_at
end
|