diff options
Diffstat (limited to 'lib/gitlab/email/handler/create_issue_handler.rb')
-rw-r--r-- | lib/gitlab/email/handler/create_issue_handler.rb | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/gitlab/email/handler/create_issue_handler.rb b/lib/gitlab/email/handler/create_issue_handler.rb index 7e5fa5f5cd2..50928f0d59e 100644 --- a/lib/gitlab/email/handler/create_issue_handler.rb +++ b/lib/gitlab/email/handler/create_issue_handler.rb @@ -11,16 +11,19 @@ module Gitlab class CreateIssueHandler < BaseHandler include ReplyProcessing - HANDLER_REGEX = /\A.+-(?<project_id>.+)-(?<incoming_email_token>.+)-issue\z/.freeze + HANDLER_REGEX = /\A#{HANDLER_ACTION_BASE_REGEX}-issue\z/.freeze HANDLER_REGEX_LEGACY = /\A(?<project_path>[^\+]*)\+(?<incoming_email_token>.*)\z/.freeze def initialize(mail, mail_key) super(mail, mail_key) - if matched = HANDLER_REGEX.match(mail_key.to_s) - @project_id, @incoming_email_token = matched.captures + if !mail_key&.include?('/') && (matched = HANDLER_REGEX.match(mail_key.to_s)) + @project_slug = matched[:project_slug] + @project_id = matched[:project_id]&.to_i + @incoming_email_token = matched[:incoming_email_token] elsif matched = HANDLER_REGEX_LEGACY.match(mail_key.to_s) - @project_path, @incoming_email_token = matched.captures + @project_path = matched[:project_path] + @incoming_email_token = matched[:incoming_email_token] end end @@ -45,18 +48,8 @@ module Gitlab end # rubocop: enable CodeReuse/ActiveRecord - def project - @project ||= if project_id - Project.find_by_id(project_id) - else - Project.find_by_full_path(project_path) - end - end - private - attr_reader :project_id, :project_path, :incoming_email_token - def create_issue Issues::CreateService.new( project, |