FEATURE: clean API method for reading a single notification

This commit is contained in:
Sam
2016-09-16 16:14:00 +10:00
parent 0290619669
commit 75f3f7fcbd
5 changed files with 34 additions and 9 deletions

View File

@@ -46,11 +46,14 @@ class NotificationsController < ApplicationController
end
def mark_read
Notification.where(user_id: current_user.id).includes(:topic).where(read: false).update_all(read: true)
current_user.saw_notification_id(Notification.recent_report(current_user, 1).max.try(:id))
current_user.reload
current_user.publish_notifications_state
if params[:id]
Notification.read(current_user, [params[:id].to_i])
else
Notification.where(user_id: current_user.id).includes(:topic).where(read: false).update_all(read: true)
current_user.saw_notification_id(Notification.recent_report(current_user, 1).max.try(:id))
current_user.reload
current_user.publish_notifications_state
end
render json: success_json
end