2017-08-24 02:20:36 -04:00
|
|
|
require 'gitlab/email/handler/create_merge_request_handler'
|
2016-05-21 12:40:08 -04:00
|
|
|
require 'gitlab/email/handler/create_note_handler'
|
|
|
|
require 'gitlab/email/handler/create_issue_handler'
|
2016-10-12 13:07:36 -04:00
|
|
|
require 'gitlab/email/handler/unsubscribe_handler'
|
2016-05-21 12:40:08 -04:00
|
|
|
|
2016-05-18 18:19:25 -04:00
|
|
|
module Gitlab
|
|
|
|
module Email
|
2016-05-21 12:40:08 -04:00
|
|
|
module Handler
|
2018-08-23 05:04:41 -04:00
|
|
|
def self.handlers
|
|
|
|
@handlers ||= load_handlers
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.load_handlers
|
|
|
|
[
|
|
|
|
UnsubscribeHandler,
|
|
|
|
CreateNoteHandler,
|
|
|
|
CreateMergeRequestHandler,
|
|
|
|
CreateIssueHandler
|
|
|
|
]
|
|
|
|
end
|
2016-06-15 04:31:28 -04:00
|
|
|
|
2016-05-21 12:40:08 -04:00
|
|
|
def self.for(mail, mail_key)
|
2018-08-23 05:04:41 -04:00
|
|
|
handlers.find do |klass|
|
2016-05-21 12:40:08 -04:00
|
|
|
handler = klass.new(mail, mail_key)
|
|
|
|
break handler if handler.can_handle?
|
|
|
|
end
|
2016-05-18 18:19:25 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|