diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-08-21 09:38:40 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-08-21 09:38:40 +0000 |
commit | 89f6584fb30544dbd27c291c3b62e3f2b0399e63 (patch) | |
tree | 6a364a9b79bcabb4df38bb7adf4a1190f8b83a7a /app/controllers | |
parent | 9174d60ba1ce3e183396f360c6e41ed23540b6d0 (diff) | |
parent | 926bf71e511e084fa033b4e96f5b4067e0eeca0a (diff) | |
download | gitlab-ce-89f6584fb30544dbd27c291c3b62e3f2b0399e63.tar.gz |
Merge branch '63372-award-emoji-services' into 'master'
Add service classes for mutating AwardEmoji
Closes #63372
See merge request gitlab-org/gitlab-ce!29782
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/autocomplete_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/concerns/toggle_award_emoji.rb | 19 |
2 files changed, 3 insertions, 18 deletions
diff --git a/app/controllers/autocomplete_controller.rb b/app/controllers/autocomplete_controller.rb index f111c7ca8cc..30a567c3bef 100644 --- a/app/controllers/autocomplete_controller.rb +++ b/app/controllers/autocomplete_controller.rb @@ -36,7 +36,7 @@ class AutocompleteController < ApplicationController end def award_emojis - render json: AwardedEmojiFinder.new(current_user).execute + render json: AwardEmojis::CollectUserEmojiService.new(current_user).execute end def merge_request_target_branches diff --git a/app/controllers/concerns/toggle_award_emoji.rb b/app/controllers/concerns/toggle_award_emoji.rb index 97b343f8b1a..24d178781d6 100644 --- a/app/controllers/concerns/toggle_award_emoji.rb +++ b/app/controllers/concerns/toggle_award_emoji.rb @@ -7,12 +7,9 @@ module ToggleAwardEmoji authenticate_user! name = params.require(:name) - if awardable.user_can_award?(current_user) - awardable.toggle_award_emoji(name, current_user) - - todoable = to_todoable(awardable) - TodoService.new.new_award_emoji(todoable, current_user) if todoable + service = AwardEmojis::ToggleService.new(awardable, name, current_user).execute + if service[:status] == :success render json: { ok: true } else render json: { ok: false } @@ -21,18 +18,6 @@ module ToggleAwardEmoji private - def to_todoable(awardable) - case awardable - when Note - # we don't create todos for personal snippet comments for now - awardable.for_personal_snippet? ? nil : awardable.noteable - when MergeRequest, Issue - awardable - when Snippet - nil - end - end - def awardable raise NotImplementedError end |