2018-08-23 05:22:23 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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
|
|
|
|
[
|
|
|
|
CreateNoteHandler,
|
2020-05-07 05:09:51 -04:00
|
|
|
CreateIssueHandler,
|
|
|
|
UnsubscribeHandler,
|
2020-07-14 11:09:05 -04:00
|
|
|
CreateMergeRequestHandler,
|
|
|
|
ServiceDeskHandler
|
2018-08-23 05:04:41 -04:00
|
|
|
]
|
|
|
|
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
|