Sha256: 06c878c000e2ed3d7517a273a85fbaf7ec02c000c8d744cac43cbf0e7d6834c1

Contents?: true

Size: 937 Bytes

Versions: 54

Compression:

Stored size: 937 Bytes

Contents

# frozen_string_literal: true

module Motor
  class NotificationsController < ApiBaseController
    wrap_parameters :data, except: %i[include fields]

    load_and_authorize_resource :notification

    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

    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

    private

    def notification_params
      params.require(:data).permit(:status)
    end
  end
end

Version data entries

54 entries across 54 versions & 6 rubygems

Version Path
motor-admin-0.4.34 app/controllers/motor/notifications_controller.rb
motor-admin-0.4.33 app/controllers/motor/notifications_controller.rb
motor-admin-0.4.32 app/controllers/motor/notifications_controller.rb
motor-admin-0.4.31 app/controllers/motor/notifications_controller.rb
motor-admin-0.4.30 app/controllers/motor/notifications_controller.rb
motor-admin-0.4.29 app/controllers/motor/notifications_controller.rb
motor-admin-0.4.28 app/controllers/motor/notifications_controller.rb
motor-admin-cstham8-0.4.35 app/controllers/motor/notifications_controller.rb
motor-admin-cstham8-0.4.34 app/controllers/motor/notifications_controller.rb
motor-admin-cstham8-0.4.33 app/controllers/motor/notifications_controller.rb
motor-admin-cstham8-0.4.32 app/controllers/motor/notifications_controller.rb
motor-admin-cstham8-0.4.31 app/controllers/motor/notifications_controller.rb
motor-admin-cstham8-0.4.30 app/controllers/motor/notifications_controller.rb
motor-admin-cstham8-0.4.29 app/controllers/motor/notifications_controller.rb
motor-admin-cstham8-0.4.28 app/controllers/motor/notifications_controller.rb
motor-admin-cstham8-0.4.27 app/controllers/motor/notifications_controller.rb
motor-admin-0.4.27 app/controllers/motor/notifications_controller.rb
motor-admin-unosquare-0.4.28 app/controllers/motor/notifications_controller.rb
motor-admin-unosquare-0.4.27 app/controllers/motor/notifications_controller.rb
motor-admin-pz-0.4.26 app/controllers/motor/notifications_controller.rb