Class: SupportsMailbox

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

Constant Summary collapse

RECIPIENT_FORMAT =
/support(?:_case)?\+id(.+)@/i

Constants inherited from ApplicationMailbox

ApplicationMailbox::DIRECT_FILE_EXTENSIONS, ApplicationMailbox::FETCHABLE_MIME_TYPES, ApplicationMailbox::FETCH_MAX_SIZE, ApplicationMailbox::GDRIVE_FILE_RE, ApplicationMailbox::GDRIVE_OPEN_RE, ApplicationMailbox::MAX_FILENAME_LENGTH

Instance Method Summary collapse

Methods inherited from ApplicationMailbox

#attempt_url_download, #collect_fetchable_urls, #create_activity, #create_communication, #fetch_linked_files, #find_sender_party, #get_resource_id, #inline_or_attachment_part?, #process_attachments, #process_content, #replace_cid_references, #sanitize_attachment_filename

Instance Method Details

#get_support_caseObject



32
33
34
35
# File 'app/mailboxes/supports_mailbox.rb', line 32

def get_support_case
  @support_case = SupportCase.find(get_resource_id) rescue nil
  Rails.logger.info "Support Mailbox, support case retrieved. ID: #{@support_case&.id}"
end

#processObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/mailboxes/supports_mailbox.rb', line 4

def process
  get_support_case

  return unless @support_case.present?

  Rails.logger.info "Processing Support Mail for Support Case ID #{@support_case.id}"
  if mail.from.any?{|a| a.include?('@warmlyyours.com')}
    comm_state = 'sent'
    comm_direction = 'outbound'
    act_type = 'EMAILOUT'
    complete_act = true
  else
    comm_state = 'received'
    comm_direction = 'inbound'
    act_type = 'EMAILINTECH'
    complete_act = false
  end

  note = process_content(mail)

  comm = create_communication(@support_case, mail, note, comm_state, comm_direction)

  process_attachments(comm, mail)
  
  create_activity(@support_case, act_type, @support_case.assigned_to, comm, complete_act)
 
end