Module: Mailboxer::Models::Messageable
- Defined in:
- app/models/messageable.rb
Overview
:nodoc:
Instance Method Summary collapse
- #attach_files(attachments, message) ⇒ Object
- #build_convo(subject, message_timestamp) ⇒ Object
- #build_message(convo, recipients, msg_body, subject, message_timestamp) ⇒ Object
- #reply(conversation, recipients, reply_body, subject = nil, sanitize_text = true, attachment = nil) ⇒ Object
- #reply_to_sender_mult_attach(receipt, reply_body, subject = nil, sanitize_text = true, attachments = nil) ⇒ Object
- #send_message_mult_attach(recipients, msg_body, subject, sanitize_text = true, attachments = nil, message_timestamp = Time.now) ⇒ Object
Instance Method Details
#attach_files(attachments, message) ⇒ Object
60 61 62 63 64 65 |
# File 'app/models/messageable.rb', line 60 def attach_files(, ) return if .blank? .each do |m| . << MessageAttachment.new(file: m[:file]) end end |
#build_convo(subject, message_timestamp) ⇒ Object
40 41 42 43 44 45 46 |
# File 'app/models/messageable.rb', line 40 def build_convo(subject, ) ::Mailboxer::ConversationBuilder.new( subject: subject, created_at: , updated_at: ).build end |
#build_message(convo, recipients, msg_body, subject, message_timestamp) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/messageable.rb', line 48 def (convo, recipients, msg_body, subject, ) ::Mailboxer::MessageBuilder.new( sender: self, conversation: convo, recipients: recipients, body: msg_body, subject: subject, created_at: , updated_at: ).build end |
#reply(conversation, recipients, reply_body, subject = nil, sanitize_text = true, attachment = nil) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'app/models/messageable.rb', line 23 def reply(conversation, recipients, reply_body, subject=nil, sanitize_text=true, =nil) subject = subject || "#{conversation.subject}" (conversation, recipients, reply_body, subject, = Time.now) end |
#reply_to_sender_mult_attach(receipt, reply_body, subject = nil, sanitize_text = true, attachments = nil) ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/models/messageable.rb', line 32 def reply_to_sender_mult_attach(receipt, reply_body, subject = nil, sanitize_text = true, = nil) = reply(receipt.conversation, receipt..sender, reply_body, subject, sanitize_text) attach_files(, ) .deliver false, sanitize_text end |
#send_message_mult_attach(recipients, msg_body, subject, sanitize_text = true, attachments = nil, message_timestamp = Time.now) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/messageable.rb', line 11 def (recipients, msg_body, subject, sanitize_text = true, = nil, = Time.now) convo = build_convo(subject, ) = (convo, recipients, msg_body, subject, ) attach_files(, ) .deliver false, sanitize_text end |