2013-02-05 13:16:51 -06:00
|
|
|
class NotificationsController < ApplicationController
|
|
|
|
|
|
|
|
before_filter :ensure_logged_in
|
|
|
|
|
|
|
|
def index
|
2014-02-13 14:20:56 -06:00
|
|
|
notifications = Notification.recent_report(current_user, 10)
|
2013-05-16 02:30:30 -05:00
|
|
|
|
2014-06-11 19:50:41 -05:00
|
|
|
if notifications.present?
|
|
|
|
# ordering can be off due to PMs
|
|
|
|
max_id = notifications.map(&:id).max
|
2014-06-07 05:17:45 -05:00
|
|
|
current_user.saw_notification_id(max_id) unless params.has_key?(:silent)
|
2014-06-11 19:50:41 -05:00
|
|
|
end
|
2013-02-05 13:16:51 -06:00
|
|
|
current_user.reload
|
|
|
|
current_user.publish_notifications_state
|
|
|
|
|
|
|
|
render_serialized(notifications, NotificationSerializer)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|