Class: Cats::Core::NotificationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/cats/core/notifications_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate, #current_user, #skip_bullet

Instance Method Details

#indexObject



6
7
8
9
# File 'app/controllers/cats/core/notifications_controller.rb', line 6

def index
  data = Notification.messages(current_user.notifications.newest_first)
  render json: {success: true, data: data}
end

#mark_as_readObject



21
22
23
24
# File 'app/controllers/cats/core/notifications_controller.rb', line 21

def mark_as_read
  @notification.mark_as_read!
  render json: {success: true, data: @notification.message}
end

#mark_as_unreadObject



26
27
28
29
# File 'app/controllers/cats/core/notifications_controller.rb', line 26

def mark_as_unread
  @notification.mark_as_unread!
  render json: {success: true, data: @notification.message}
end

#readObject



11
12
13
14
# File 'app/controllers/cats/core/notifications_controller.rb', line 11

def read
  data = Notification.messages(current_user.notifications.read.newest_first)
  render json: {success: true, data: data}
end

#unreadObject



16
17
18
19
# File 'app/controllers/cats/core/notifications_controller.rb', line 16

def unread
  data = Notification.messages(current_user.notifications.unread.newest_first)
  render json: {success: true, data: data}
end