2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
module ToggleAwardEmoji
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
def toggle_award_emoji
|
2017-08-17 22:00:37 +05:30
|
|
|
authenticate_user!
|
2016-06-16 23:09:34 +05:30
|
|
|
name = params.require(:name)
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
service = AwardEmojis::ToggleService.new(awardable, name, current_user).execute
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
if service[:status] == :success
|
2016-09-29 09:46:39 +05:30
|
|
|
render json: { ok: true }
|
|
|
|
else
|
|
|
|
render json: { ok: false }
|
|
|
|
end
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def awardable
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
end
|