mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 19:44:39 +08:00
FIX: ensure 'notifications_state' is up to date after creating a notification
This commit is contained in:
@ -59,22 +59,21 @@ class Notification < ActiveRecord::Base
|
||||
|
||||
def self.mark_posts_read(user, topic_id, post_numbers)
|
||||
count = Notification
|
||||
.where(user_id: user.id,
|
||||
topic_id: topic_id,
|
||||
post_number: post_numbers,
|
||||
read: false)
|
||||
.update_all("read = 't'")
|
||||
.where(user_id: user.id)
|
||||
.where(topic_id: topic_id)
|
||||
.where(post_number: post_numbers)
|
||||
.where(read: false)
|
||||
.update_all(read: true)
|
||||
|
||||
if count > 0
|
||||
user.publish_notifications_state
|
||||
end
|
||||
user.publish_notifications_state if count > 0
|
||||
|
||||
count
|
||||
end
|
||||
|
||||
def self.read(user, notification_ids)
|
||||
count = Notification.where(user_id: user.id)
|
||||
count = Notification
|
||||
.where(id: notification_ids)
|
||||
.where(user_id: user.id)
|
||||
.where(read: false)
|
||||
.update_all(read: true)
|
||||
|
||||
@ -202,7 +201,7 @@ class Notification < ActiveRecord::Base
|
||||
protected
|
||||
|
||||
def refresh_notification_count
|
||||
user.publish_notifications_state
|
||||
user.reload.publish_notifications_state
|
||||
end
|
||||
|
||||
def send_email
|
||||
|
Reference in New Issue
Block a user