Skip to content
Snippets Groups Projects
Commit 863d8e5a authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

use split and try to unify error raising

parent c64cd113
No related branches found
No related tags found
1 merge request!3363Implement #3243 New Issue by email
Loading
Loading
@@ -5,8 +5,16 @@ module Gitlab
module Email
module Handler
class CreateIssueHandler < BaseHandler
attr_reader :project_namespace, :authentication_token
def initialize(mail, mail_key)
super(mail, mail_key)
@project_namespace, @authentication_token =
mail_key && mail_key.split('+', 2)
end
def can_handle?
!!project
!!(project_namespace && project)
end
 
def execute
Loading
Loading
@@ -28,14 +36,6 @@ module Gitlab
end
 
private
def authentication_token
mail_key[/[^\+]+$/]
end
def project_namespace
mail_key[/^[^\+]+/]
end
def create_issue
Issues::CreateService.new(
project,
Loading
Loading
Loading
Loading
@@ -6,7 +6,7 @@ module Gitlab
module Handler
class CreateNoteHandler < BaseHandler
def can_handle?
!!sent_notification
!!(mail_key && sent_notification)
end
 
def execute
Loading
Loading
Loading
Loading
@@ -28,8 +28,6 @@ module Gitlab
mail = build_mail
mail_key = extract_mail_key(mail)
 
raise SentNotificationNotFoundError unless mail_key
if handler = Handler.for(mail, mail_key)
handler.execute
elsif mail_key =~ %r{/|\+}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment