mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 23:48:45 +08:00
29 lines
714 B
Ruby
29 lines
714 B
Ruby
# frozen_string_literal: true
|
|
|
|
class TopicTrackingStateSerializer < ApplicationSerializer
|
|
attributes :topic_id,
|
|
:highest_post_number,
|
|
:last_read_post_number,
|
|
:created_at,
|
|
:category_id,
|
|
:notification_level,
|
|
:created_in_new_period,
|
|
:unread_not_too_old,
|
|
:treat_as_new_topic_start_date,
|
|
:tags
|
|
|
|
def created_in_new_period
|
|
return true if !scope
|
|
object.created_at >= treat_as_new_topic_start_date
|
|
end
|
|
|
|
def unread_not_too_old
|
|
return true if object.first_unread_at.blank?
|
|
object.updated_at >= object.first_unread_at
|
|
end
|
|
|
|
def include_tags?
|
|
object.respond_to?(:tags)
|
|
end
|
|
end
|