summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2019-08-21 09:38:40 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2019-08-21 09:38:40 +0000
commit89f6584fb30544dbd27c291c3b62e3f2b0399e63 (patch)
tree6a364a9b79bcabb4df38bb7adf4a1190f8b83a7a /app/controllers
parent9174d60ba1ce3e183396f360c6e41ed23540b6d0 (diff)
parent926bf71e511e084fa033b4e96f5b4067e0eeca0a (diff)
downloadgitlab-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.rb2
-rw-r--r--app/controllers/concerns/toggle_award_emoji.rb19
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