Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/work_items/delete_service.rb')
-rw-r--r--app/services/work_items/delete_service.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/services/work_items/delete_service.rb b/app/services/work_items/delete_service.rb
new file mode 100644
index 00000000000..1093a403a1c
--- /dev/null
+++ b/app/services/work_items/delete_service.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+module WorkItems
+ class DeleteService < Issuable::DestroyService
+ def execute(work_item)
+ unless current_user.can?(:delete_work_item, work_item)
+ return ::ServiceResponse.error(message: 'User not authorized to delete work item')
+ end
+
+ if super
+ ::ServiceResponse.success
+ else
+ ::ServiceResponse.error(message: work_item.errors.full_messages)
+ end
+ end
+ end
+end