BigW Consortium Gitlab

Commit 863d8e5a by Lin Jen-Shin

use split and try to unify error raising

parent c64cd113
......@@ -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
......@@ -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,
......
......@@ -6,7 +6,7 @@ module Gitlab
module Handler
class CreateNoteHandler < BaseHandler
def can_handle?
!!sent_notification
!!(mail_key && sent_notification)
end
def execute
......
......@@ -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{/|\+}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment