Class: WechatMailbox

Inherits:
ApplicationMailbox show all
Defined in:
app/mailboxes/wechat_mailbox.rb

Instance Method Summary collapse

Instance Method Details

#forwarderObject



11
12
13
14
15
# File 'app/mailboxes/wechat_mailbox.rb', line 11

def forwarder
  return @forwarder if defined? @forwarder
  ident = mail.to[0].to_s.split('@')[0]
  @forwarder = Register.find_by(mobile: ident)
end

#processObject



3
4
5
6
7
8
9
# File 'app/mailboxes/wechat_mailbox.rb', line 3

def process
  html = Nokogiri::HTML(mail.body.to_s)
  if forwarder
    forwarder.email_code = html.search('p.mmsgLetterDigital')[0]&.inner_text
    forwarder.save
  end
end