mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 07:37:55 +08:00
DEV: Publish DiscourseEvent in TopicUser.track_visit for first visit (#27975)
This commit is contained in:

committed by
GitHub

parent
d13dab5b68
commit
6e77107ccc
@ -299,8 +299,10 @@ class TopicUser < ActiveRecord::Base
|
||||
def track_visit!(topic_id, user_id)
|
||||
now = DateTime.now
|
||||
rows = TopicUser.where(topic_id: topic_id, user_id: user_id).update_all(last_visited_at: now)
|
||||
|
||||
change(user_id, topic_id, last_visited_at: now, first_visited_at: now) if rows == 0
|
||||
if rows == 0
|
||||
change(user_id, topic_id, last_visited_at: now, first_visited_at: now)
|
||||
DiscourseEvent.trigger(:user_first_visit_to_topic, user_id: user_id, topic_id: topic_id)
|
||||
end
|
||||
end
|
||||
|
||||
# Update the last read and the last seen post count, but only if it doesn't exist.
|
||||
|
Reference in New Issue
Block a user