Class: Motor::NotificationsController
- Inherits:
-
ApiBaseController
- Object
- ActionController::API
- ApiBaseController
- Motor::NotificationsController
- Defined in:
- app/controllers/motor/notifications_controller.rb
Instance Method Summary collapse
Methods included from CurrentAbility
Methods included from CurrentUserMethod
Instance Method Details
#index ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/motor/notifications_controller.rb', line 9 def index @notifications = Motor::ApiQuery.call(@notifications.where(recipient: current_user).order(created_at: :desc), params) render json: { data: Motor::ApiQuery::BuildJson.call(@notifications, params, current_ability), meta: Motor::ApiQuery::BuildMeta.call(@notifications, params) } end |
#update ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/controllers/motor/notifications_controller.rb', line 19 def update @notification.update!(notification_params) Motor::NotificationsChannel.broadcast_to(current_user, ['update', @notification.as_json(include: i[record])]) render json: { data: Motor::ApiQuery::BuildJson.call(@notification, params, current_ability) } end |