Class: Api::V5::NotificationsController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Api::V5::NotificationsController
show all
- Includes:
- Concerns::Authorization
- Defined in:
- app/controllers/api/v5/notifications_controller.rb
Overview
Constant Summary
BaseController::CACHE_NAMESPACE, BaseController::INTERNAL_SERVER_ERROR_MESSAGE, BaseController::ResponseSchema
Instance Method Summary
collapse
#identity_cache_memoization
#append_info_to_payload
#my_response_cache
Instance Method Details
#index ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'app/controllers/api/v5/notifications_controller.rb', line 6
def index
page = params.fetch(:page, {})
filter = Api::V5::NotificationsFilter.new
filter.init_default(current_user.id).page_number(page[:number]).per_page(page[:size])
(true)
options = {}
render json: filter.as_json(serialization_context, minor_version_param, options).merge(success: true, message: nil)
end
|
#mark_all_as_read ⇒ Object
23
24
25
26
27
28
29
|
# File 'app/controllers/api/v5/notifications_controller.rb', line 23
def mark_all_as_read
Message.where(user: current_user, unread: true).find_each do |m|
m.update unread: false
end
render json: { data: [], success: true, message: nil }
end
|
#mark_read ⇒ Object
16
17
18
19
20
21
|
# File 'app/controllers/api/v5/notifications_controller.rb', line 16
def mark_read
message = Message.find params.require(:notification_id)
success = message.update unread: false
render json: resource_as_json(message, Api::V5::NotificationSerializer, {}).merge(success: success, message: message.errors.full_messages.to_sentence)
end
|