diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-04-06 21:19:37 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-04-11 11:51:43 +0300 |
commit | 04c7d0d55500e6f118bd17153f3af11e83fce826 (patch) | |
tree | 7976d051ad4138dd020e78e2fd616f0791bd7123 /app/models | |
parent | 71ccfde322b633e9245bee6acba1e64cb7640f19 (diff) |
Prevent awarding emoji when a project is archived
This prevents performing the requests, and disables all emoji reaction buttons
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/awardable.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/app/models/concerns/awardable.rb b/app/models/concerns/awardable.rb index d8394415362..fce37e7f78e 100644 --- a/app/models/concerns/awardable.rb +++ b/app/models/concerns/awardable.rb @@ -79,11 +79,7 @@ module Awardable end def user_can_award?(current_user, name) - if user_authored?(current_user) - !awardable_votes?(normalize_name(name)) - else - true - end + awardable_by_user?(current_user, name) && Ability.allowed?(current_user, :award_emoji, self) end def user_authored?(current_user) @@ -119,4 +115,12 @@ module Awardable def normalize_name(name) Gitlab::Emoji.normalize_emoji_name(name) end + + def awardable_by_user?(current_user, name) + if user_authored?(current_user) + !awardable_votes?(normalize_name(name)) + else + true + end + end end |