2018-08-23 09:22:23 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-05-18 22:19:25 +00:00
|
|
|
module Gitlab
|
|
|
|
module Email
|
2016-05-21 16:40:08 +00:00
|
|
|
module Handler
|
2018-08-23 09:04:41 +00:00
|
|
|
def self.handlers
|
|
|
|
@handlers ||= load_handlers
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.load_handlers
|
|
|
|
[
|
|
|
|
UnsubscribeHandler,
|
|
|
|
CreateNoteHandler,
|
|
|
|
CreateMergeRequestHandler,
|
|
|
|
CreateIssueHandler
|
|
|
|
]
|
|
|
|
end
|
2016-06-15 08:31:28 +00:00
|
|
|
|
2016-05-21 16:40:08 +00:00
|
|
|
def self.for(mail, mail_key)
|
2018-08-23 09:04:41 +00:00
|
|
|
handlers.find do |klass|
|
2016-05-21 16:40:08 +00:00
|
|
|
handler = klass.new(mail, mail_key)
|
|
|
|
break handler if handler.can_handle?
|
|
|
|
end
|
2016-05-18 22:19:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|