Sha256: 8517cb77f80d8ab2c6a66389f6d5442aad843545b4c0eebc9b2b8d3e054aeb84

Contents?: true

Size: 896 Bytes

Versions: 54

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

54 entries across 54 versions & 6 rubygems

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