summaryrefslogtreecommitdiff
path: root/app/services/notes/slash_commands_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/notes/slash_commands_service.rb')
-rw-r--r--app/services/notes/slash_commands_service.rb21
1 files changed, 12 insertions, 9 deletions
diff --git a/app/services/notes/slash_commands_service.rb b/app/services/notes/slash_commands_service.rb
index 4a9a8a64653..2edbd39a9e7 100644
--- a/app/services/notes/slash_commands_service.rb
+++ b/app/services/notes/slash_commands_service.rb
@@ -5,9 +5,18 @@ module Notes
'MergeRequest' => MergeRequests::UpdateService
}
- def supported?(note)
+ def self.noteable_update_service(note)
+ UPDATE_SERVICES[note.noteable_type]
+ end
+
+ def self.supported?(note, current_user)
noteable_update_service(note) &&
- can?(current_user, :"update_#{note.noteable_type.underscore}", note.noteable)
+ current_user &&
+ current_user.can?(:"update_#{note.noteable_type.underscore}", note.noteable)
+ end
+
+ def supported?(note)
+ self.class.supported?(note, current_user)
end
def extract_commands(note)
@@ -21,13 +30,7 @@ module Notes
return if command_params.empty?
return unless supported?(note)
- noteable_update_service(note).new(project, current_user, command_params).execute(note.noteable)
- end
-
- private
-
- def noteable_update_service(note)
- UPDATE_SERVICES[note.noteable_type]
+ self.class.noteable_update_service(note).new(project, current_user, command_params).execute(note.noteable)
end
end
end