Class: Notifications::NotificationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/notifications/notifications_controller.rb

Instance Method Summary collapse

Instance Method Details

#cleanObject


14
15
16
17
# File 'app/controllers/notifications/notifications_controller.rb', line 14

def clean
  Notification.where(user_id: current_user.id).delete_all
  redirect_to notifications_path
end

#indexObject


3
4
5
6
7
8
9
10
11
12
# File 'app/controllers/notifications/notifications_controller.rb', line 3

def index
  @notifications = current_user.notifications.includes(:actor).order('id desc').page(params[:page])

  unread_ids = []
  @notifications.each do |n|
    unread_ids << n.id unless n.read?
  end
  Notification.read!(unread_ids)
  Notification.realtime_push_to_client(current_user)
end