mirror of
https://github.com/discourse/discourse.git
synced 2026-09-05 04:40:41 -05:00
fixed a pile of notification craziness
addes some tests around post timings
This commit is contained in:
@@ -39,4 +39,32 @@ class PostTiming < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.process_timings(current_user, topic_id, highest_seen, topic_time, timings)
|
||||
current_user.update_time_read!
|
||||
|
||||
original_unread = current_user.unread_notifications_by_type
|
||||
timings.each do |post_number, time|
|
||||
if post_number >= 0
|
||||
PostTiming.record_timing(topic_id: topic_id,
|
||||
post_number: post_number,
|
||||
user_id: current_user.id,
|
||||
msecs: time)
|
||||
end
|
||||
end
|
||||
|
||||
total_changed = 0
|
||||
if timings.length > 0
|
||||
total_changed = Notification.mark_posts_read(current_user, topic_id, timings.map{|t| t[0]})
|
||||
end
|
||||
|
||||
TopicUser.update_last_read(current_user, topic_id, highest_seen, topic_time)
|
||||
|
||||
if total_changed > 0
|
||||
current_user.reload
|
||||
current_user.publish_notifications_state
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user