Class: Comee::Core::NotificationsController
Instance Method Summary
collapse
#application_code, #authenticate, #current_application, #current_user, #render_content, #render_error, #skip_bullet
Methods included from Pagination
#default_per_page, #order_by, #order_direction, #page_no, #paginate, #paginate_offset, #per_page
Instance Method Details
#index ⇒ Object
6
7
8
9
|
# File 'app/controllers/comee/core/notifications_controller.rb', line 6
def index
data = Notification.messages(current_user.notifications.newest_first)
render_content(data)
end
|
#mark_as_read ⇒ Object
21
22
23
24
|
# File 'app/controllers/comee/core/notifications_controller.rb', line 21
def mark_as_read
@notification.mark_as_read!
render json: {success: true, data: @notification.message}
end
|
#mark_as_unread ⇒ Object
26
27
28
29
|
# File 'app/controllers/comee/core/notifications_controller.rb', line 26
def mark_as_unread
@notification.mark_as_unread!
render json: {success: true, data: @notification.message}
end
|
#notify ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/comee/core/notifications_controller.rb', line 31
def notify
NotificationMailer.with(
user: current_user,
recipients: notify_params[:recipients],
subject: notify_params[:subject],
email_body: notify_params[:body],
files: notify_params[:files]
).notify.deliver_now
render json: {success: true}
rescue StandardError => e
render_error(e)
end
|
#read ⇒ Object
11
12
13
14
|
# File 'app/controllers/comee/core/notifications_controller.rb', line 11
def read
data = Notification.messages(current_user.notifications.read.newest_first)
render_content(data)
end
|
#unread ⇒ Object
16
17
18
19
|
# File 'app/controllers/comee/core/notifications_controller.rb', line 16
def unread
data = Notification.messages(current_user.notifications.unread.newest_first)
render_content(data)
end
|