diff options
author | Rémy Coutable <remy@rymai.me> | 2016-08-09 19:26:45 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-08-13 00:06:11 +0200 |
commit | 7cc4ab14b8a2f1d7d374a320b79374764527659f (patch) | |
tree | 6dfd4067d98db291f9b8f5db05909967e0c7cd27 /app/services/slash_commands | |
parent | a54fdc384fee9daeab1b9fb638dae5dce4e4be15 (diff) | |
download | gitlab-ce-7cc4ab14b8a2f1d7d374a320b79374764527659f.tar.gz |
New Notes::SlashCommandsService service
Check for update_issuable permission in Notes::SlashCommandsService
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/services/slash_commands')
-rw-r--r-- | app/services/slash_commands/interpret_service.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/services/slash_commands/interpret_service.rb b/app/services/slash_commands/interpret_service.rb index 2c92a4f7de5..bff61683976 100644 --- a/app/services/slash_commands/interpret_service.rb +++ b/app/services/slash_commands/interpret_service.rb @@ -2,9 +2,12 @@ module SlashCommands class InterpretService < BaseService include Gitlab::SlashCommands::Dsl + attr_reader :noteable + # Takes a text and interpret the commands that are extracted from it. # Returns a hash of changes to be applied to a record. - def execute(content) + def execute(content, noteable) + @noteable = noteable @updates = {} commands = extractor.extract_commands!(content) @@ -105,6 +108,8 @@ module SlashCommands desc 'Set a due date' params '<YYYY-MM-DD> | <N days>' command :due_date do |due_date_param| + return unless noteable.respond_to?(:due_date) + due_date = begin Time.now + ChronicDuration.parse(due_date_param) rescue ChronicDuration::DurationParseError @@ -116,6 +121,8 @@ module SlashCommands desc 'Remove due date' command :clear_due_date do + return unless noteable.respond_to?(:due_date) + @updates[:due_date] = nil end |