Sha256: 8517cb77f80d8ab2c6a66389f6d5442aad843545b4c0eebc9b2b8d3e054aeb84

Contents?: true

Size: 896 Bytes

Versions: 56

Compression:

Stored size: 896 Bytes

Contents

# frozen_string_literal: true

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

    load_and_authorize_resource :reminder

    def create
      @reminder.update!(author: current_user, recipient: current_user)

      broadcast_note_update(@reminder.record)

      render json: { data: Motor::ApiQuery::BuildJson.call(@reminder, params, current_ability) }
    end

    def destroy
      @reminder.destroy!

      broadcast_note_update(@reminder.record)

      head :ok
    end

    private

    def broadcast_note_update(note)
      Motor::NotesChannel.broadcast_to(
        note.values_at(:record_type, :record_id).join(':'),
        ['update', note.as_json(include: %i[author tags reminders])]
      )
    end

    def reminder_params
      params.require(:data).permit(:record_id, :record_type, :scheduled_at)
    end
  end
end

Version data entries

56 entries across 56 versions & 6 rubygems

Version Path
motor-admin-unosquare-0.4.27 app/controllers/motor/reminders_controller.rb
motor-admin-pz-0.4.26 app/controllers/motor/reminders_controller.rb
motor-admin-0.4.26 app/controllers/motor/reminders_controller.rb
motor-admin-0.4.25 app/controllers/motor/reminders_controller.rb
motor-admin-0.4.24 app/controllers/motor/reminders_controller.rb
motor-admin-0.4.23 app/controllers/motor/reminders_controller.rb
motor-admin-pz-0.4.22 app/controllers/motor/reminders_controller.rb
motor-admin-0.4.22 app/controllers/motor/reminders_controller.rb
motor-admin-pz-0.4.21 app/controllers/motor/reminders_controller.rb
motor-admin-0.4.21 app/controllers/motor/reminders_controller.rb
motor-admin-0.4.20 app/controllers/motor/reminders_controller.rb
motor-admin-0.4.19 app/controllers/motor/reminders_controller.rb
motor-admin-pz-0.4.18.1 app/controllers/motor/reminders_controller.rb
motor-admin-0.4.18 app/controllers/motor/reminders_controller.rb
motor-admin-0.4.17 app/controllers/motor/reminders_controller.rb
motor-alexandermohan-admin-panel-0.4.161 app/controllers/motor/reminders_controller.rb
alexandermohan-admin-panel-0.4.161 app/controllers/motor/reminders_controller.rb
motor-admin-0.4.16 app/controllers/motor/reminders_controller.rb
motor-admin-pz-0.4.14 app/controllers/motor/reminders_controller.rb
motor-admin-0.4.15 app/controllers/motor/reminders_controller.rb