Commit 29f818e6 authored by barthc's avatar barthc

prevent authored awardable thumbs votes

parent 76872372
...@@ -8,12 +8,14 @@ module ToggleAwardEmoji ...@@ -8,12 +8,14 @@ module ToggleAwardEmoji
def toggle_award_emoji def toggle_award_emoji
name = params.require(:name) 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) awardable.toggle_award_emoji(name, current_user)
TodoService.new.new_award_emoji(to_todoable(awardable), current_user) TodoService.new.new_award_emoji(to_todoable(awardable), current_user)
render json: { ok: true } render json: { ok: true }
else
render json: { ok: false }
end
end end
private private
......
...@@ -64,8 +64,11 @@ module Awardable ...@@ -64,8 +64,11 @@ module Awardable
end end
def user_can_award?(current_user, name) def user_can_award?(current_user, name)
name = normalize_name(name) if user_authored?(current_user)
!(self.user_authored?(current_user) && awardable_votes?(name)) !awardable_votes?(normalize_name(name))
else
true
end
end end
def awarded_emoji?(emoji_name, current_user) 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