Module: MailRunner::InboundManagerBot
- Defined in:
- lib/mail_runner/inbound_manager_bot.rb
Class Method Summary collapse
- .deliver_mail(webhook, json_packet) ⇒ Object
- .get_mail(mailbox) ⇒ Object
- .process_inbound(mailbox, webhook, archive) ⇒ Object
- .read_mail(raw_msg) ⇒ Object
Class Method Details
.deliver_mail(webhook, json_packet) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/mail_runner/inbound_manager_bot.rb', line 33 def self.deliver_mail(webhook, json_packet) begin BotHelpers::Runner.post_to_hook(webhook, json_packet) rescue Exception => msg #interrupt exception here, so rest of inbound mail can be processed and added to queue. #otherwise, it will be lost. queued = MailRunner::QueueManagerBot.add_to_mail_queue(webhook, json_packet) end end |
.get_mail(mailbox) ⇒ Object
25 26 27 |
# File 'lib/mail_runner/inbound_manager_bot.rb', line 25 def self.get_mail(mailbox) BotHelpers::Runner.get_contents_from_mailbox(mailbox) end |
.process_inbound(mailbox, webhook, archive) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mail_runner/inbound_manager_bot.rb', line 5 def self.process_inbound(mailbox, webhook, archive) raw_mail = get_mail(mailbox) unless raw_mail.nil? raw_mail.each do |raw_msg| mail = read_mail(raw_msg) json_packet = BotHelpers::Helpers.convert_raw_mail_to_json(mail) deliver_mail(webhook, json_packet) if archive == true && queued.nil? puts "we will archive email.\n" end end end end |
.read_mail(raw_msg) ⇒ Object
29 30 31 |
# File 'lib/mail_runner/inbound_manager_bot.rb', line 29 def self.read_mail(raw_msg) Mail.read_from_string(raw_msg) end |