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 'lib/gitlab/email/handler/create_note_handler.rb')
-rw-r--r--lib/gitlab/email/handler/create_note_handler.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/gitlab/email/handler/create_note_handler.rb b/lib/gitlab/email/handler/create_note_handler.rb
index 7daa1bb96a1..817956831e3 100644
--- a/lib/gitlab/email/handler/create_note_handler.rb
+++ b/lib/gitlab/email/handler/create_note_handler.rb
@@ -33,6 +33,8 @@ module Gitlab
record: create_note,
invalid_exception: InvalidNoteError,
record_name: 'comment')
+
+ reopen_issue_on_external_participant_note
end
def metrics_event
@@ -71,6 +73,35 @@ module Gitlab
raise UserNotFoundError unless from_address && author.verified_email?(from_address)
end
+
+ def reopen_issue_on_external_participant_note
+ return unless noteable.respond_to?(:closed?)
+ return unless noteable.closed?
+ return unless author == Users::Internal.support_bot
+ return unless project.service_desk_setting&.reopen_issue_on_external_participant_note?
+
+ ::Notes::CreateService.new(
+ project,
+ Users::Internal.support_bot,
+ noteable: noteable,
+ note: build_reopen_message,
+ confidential: true
+ ).execute
+ end
+
+ def build_reopen_message
+ translated_text = s_(
+ "ServiceDesk|This issue has been reopened because it received a new comment from an external participant."
+ )
+
+ "#{assignees_references} :wave: #{translated_text}\n/reopen".lstrip
+ end
+
+ def assignees_references
+ return unless noteable.assignees.any?
+
+ noteable.assignees.map(&:to_reference).join(' ')
+ end
end
end
end