2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-16 15:09:08 -04:00
|
|
|
module ToggleAwardEmoji
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
def toggle_award_emoji
|
2016-11-28 07:03:31 -05:00
|
|
|
authenticate_user!
|
2016-04-16 15:09:08 -04:00
|
|
|
name = params.require(:name)
|
2016-05-17 13:28:17 -04:00
|
|
|
|
2019-06-17 21:44:43 -04:00
|
|
|
service = AwardEmojis::ToggleService.new(awardable, name, current_user).execute
|
2016-08-17 07:21:06 -04:00
|
|
|
|
2019-06-17 21:44:43 -04:00
|
|
|
if service[:status] == :success
|
2016-08-30 15:57:47 -04:00
|
|
|
render json: { ok: true }
|
|
|
|
else
|
|
|
|
render json: { ok: false }
|
|
|
|
end
|
2016-04-16 15:09:08 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def awardable
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
end
|