f9b0427751
* feat: added support mailbox to handle email channel (#140) Added a new mailbox called 'SupportMailbox' to handle all the incoming emails other than reply emails. An email channel will have a support email and forward email associated with it. So we filter for the right email inbox based on the support email of that inbox and route this to this mailbox. This mailbox finds the account, inbox, contact (create a new one if it does not exist) and creates a conversation and adds the email content as the first message in the conversation. Other minor things handled in this commit: * renamed the procs for routing emails in application mailbox * renamed ConversationMailbox to ReplyMailbox * Added a fallback content in MailPresenter * Added a record saving (bang) versions of enabling and disabling features in Featurable module * added new factory for the email channel refs: #140
29 lines
786 B
Ruby
29 lines
786 B
Ruby
module MailboxHelper
|
|
private
|
|
|
|
def create_message
|
|
@message = @conversation.messages.create(
|
|
account_id: @conversation.account_id,
|
|
sender: @conversation.contact,
|
|
content: processed_mail.text_content[:reply],
|
|
inbox_id: @conversation.inbox_id,
|
|
message_type: 'incoming',
|
|
content_type: 'incoming_email',
|
|
source_id: processed_mail.message_id,
|
|
content_attributes: {
|
|
email: processed_mail.serialized_data
|
|
}
|
|
)
|
|
end
|
|
|
|
def add_attachments_to_message
|
|
processed_mail.attachments.each do |mail_attachment|
|
|
attachment = @message.attachments.new(
|
|
account_id: @conversation.account_id,
|
|
file_type: 'file'
|
|
)
|
|
attachment.file.attach(mail_attachment[:blob])
|
|
end
|
|
@message.save!
|
|
end
|
|
end
|