discourse/app/serializers/topic_tracking_state_serializer.rb
Alan Guo Xiang Tan 92e1e43104
FIX: Improve reliability of topic tracking state (#17387)
The `unread_not_too_old` attribute is a little odd because there should never be a case where
the user's first_unread_at column is less than the `Topic#updated_at`
column of an unread topic. The `unread_not_too_old` attribute is causing
a bug where topic states synced into `TopicTrackingState` do not appear
as unread because the attribute does not exsist on a normal `Topic`
object and hence never set.
2022-07-14 13:44:58 +08:00

23 lines
551 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,
: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 include_tags?
object.respond_to?(:tags)
end
end