Class: Gitlab::Email::Receiver

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/email/receiver.rb

Direct Known Subclasses

ServiceDeskReceiver

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Receiver

Returns a new instance of Receiver.


9
10
11
# File 'lib/gitlab/email/receiver.rb', line 9

def initialize(raw)
  @raw = raw
end

Instance Method Details

#executeObject

Raises:


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/email/receiver.rb', line 13

def execute
  raise EmptyEmailError if @raw.blank?

  mail = build_mail

  ignore_auto_reply!(mail)

  handler = find_handler(mail)

  raise UnknownIncomingEmail unless handler

  handler.execute.tap do
    Gitlab::Metrics.add_event(handler.metrics_event, handler.metrics_params)
  end
end