Commit 29f818e6 authored by barthc's avatar barthc

prevent authored awardable thumbs votes

parent 76872372
......@@ -8,12 +8,14 @@ module ToggleAwardEmoji
def toggle_award_emoji
name = params.require(:name)
return render json: { ok: false } unless awardable.user_can_award?(current_user, name)
if awardable.user_can_award?(current_user, name)
awardable.toggle_award_emoji(name, current_user)
TodoService.new.new_award_emoji(to_todoable(awardable), current_user)
render json: { ok: true }
else
render json: { ok: false }
end
end
private
......
......@@ -64,8 +64,11 @@ module Awardable
end
def user_can_award?(current_user, name)
name = normalize_name(name)
!(self.user_authored?(current_user) && awardable_votes?(name))
if user_authored?(current_user)
!awardable_votes?(normalize_name(name))
else
true
end
end
def awarded_emoji?(emoji_name, current_user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment