summaryrefslogtreecommitdiff
path: root/app/services/slash_commands/interpret_service.rb
diff options
context:
space:
mode:
authormhasbini <mohammad.hasbini@gmail.com>2017-02-28 22:38:19 +0200
committermhasbini <mohammad.hasbini@gmail.com>2017-02-28 22:38:19 +0200
commit9f949d4e24c5939b5ea4071c3e86c514b4d82970 (patch)
tree1011567dfca77bf1d259c2ebfcf8c4f8a0d3a710 /app/services/slash_commands/interpret_service.rb
parentc5b29ed6f36779dbb96f4cdc7b1b0bce8bb8dc5e (diff)
downloadgitlab-ce-9f949d4e24c5939b5ea4071c3e86c514b4d82970.tar.gz
add /award slash command
add /award slash command; Allow posting of just an emoji in comment
Diffstat (limited to 'app/services/slash_commands/interpret_service.rb')
-rw-r--r--app/services/slash_commands/interpret_service.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/services/slash_commands/interpret_service.rb b/app/services/slash_commands/interpret_service.rb
index 3e0a85cf059..c39a2c4cf1e 100644
--- a/app/services/slash_commands/interpret_service.rb
+++ b/app/services/slash_commands/interpret_service.rb
@@ -255,6 +255,18 @@ module SlashCommands
@updates[:wip_event] = issuable.work_in_progress? ? 'unwip' : 'wip'
end
+ desc 'Toggle emoji reward'
+ params ':emoji:'
+ condition do
+ issuable.persisted?
+ end
+ command :award do |emoji|
+ name = award_emoji_name(emoji)
+ if name && issuable.user_can_award?(current_user, name)
+ @updates[:emoji_award] = name
+ end
+ end
+
desc 'Set time estimate'
params '<1w 3d 2h 14m>'
condition do
@@ -329,5 +341,10 @@ module SlashCommands
ext.references(type)
end
+
+ def award_emoji_name(emoji)
+ match = emoji.match(Banzai::Filter::EmojiFilter.emoji_pattern)
+ match[1] if match
+ end
end
end