mailboxer_multi_attach 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f53bd5ff791fc3eddafea2799561385a1744f9e
4
- data.tar.gz: de49ad3ddeead35e8807b92c89e921afbd835243
3
+ metadata.gz: 5a0763dd1759a15f9f9b73b9e69e32aed1f51e74
4
+ data.tar.gz: 6c99650728ab7ba73e276c2b6228ba54c34d460b
5
5
  SHA512:
6
- metadata.gz: 362100f98b6a635e3c7df2e2cb77ee6361c0a0ea30925ad46801503776880a9e6d65a8758ebb0723713ea64705eba0bdc5be7df8b2a4e286656c84cb06758911
7
- data.tar.gz: f834f385e3f03327272298d2e59bca7b678d20b349ee66056f0f5c7d6010a12f0796369cf3aac3362c0dcf259bd6fc6f103d36b7cde93bf2f885e43ad3633426
6
+ metadata.gz: c1a1a74f2f6947867bafbf7824747d7e8d8fb75a57d8e38be3d1c6022cf0724f71dfbf61bbf1b791014fc737266ed6e7f661b9fa7f0ce09820eef2420a2dd7dd
7
+ data.tar.gz: ed0c5d508caf903fb23447789546e39dc0b036d937d267c266b5f19eb5fae1cb3f2a8b3eb74c70de863cb86875d3f6c9614474d103f73e73a8feba1a022fe9cb
data/README.md CHANGED
@@ -12,10 +12,11 @@ Add to your gemfile and run the following
12
12
 
13
13
  ## Usage
14
14
 
15
- On any `messageable` object you utilize `send_message_mult_attach`. The following works where the entity has the `messageable` reference on its model. Make sure to use the key `:file` when submitting the attachment!
15
+ On any `messageable` object you utilize `send_message_mult_attach` or `reply_to_sender_mult_attach` to send messages. Once the message is sent you can access the attachments by calling `message_attachments` on the messageable model's message. The following works where the entity has the `messageable` reference on its model. Make sure to use the key `:file` when submitting the attachment!
16
16
 
17
17
  attachments = [{ :file => File.open('spec/testfile.txt') }, { :file => File.open('spec/1.mp4') }]
18
- entity1.send_message_mult_attach(entity2, "Body", "Subject", true, attachments)
18
+ receipt = entity1.send_message_mult_attach(entity2, "Body", "Subject", true, attachments)
19
+ entity2.reply_to_sender_mult_attach(receipt, "Body", "Subject", true, attachments)
19
20
 
20
21
  You can also not pass in attachments like the following.
21
22
 
@@ -1,6 +1,13 @@
1
1
  module Mailboxer
2
2
  module Models
3
3
  module Messageable # :nodoc:
4
+ included do
5
+ class Mailboxer::Message
6
+ has_many :message_attachments
7
+ attr_accessible :message_attachments
8
+ end
9
+ end
10
+
4
11
  def send_message_mult_attach(recipients, msg_body,
5
12
  subject, sanitize_text = true,
6
13
  attachments = nil,
@@ -9,7 +16,23 @@ module Mailboxer
9
16
  message = build_message(convo, recipients,
10
17
  msg_body, subject,
11
18
  message_timestamp)
12
- connect_message_to_message_attachments
19
+ attach_files(attachments, message)
20
+ message.deliver false, sanitize_text
21
+ end
22
+
23
+ def reply(conversation, recipients, reply_body,
24
+ subject=nil, sanitize_text=true,
25
+ attachment=nil)
26
+ subject = subject || "#{conversation.subject}"
27
+ build_message(conversation, recipients,
28
+ reply_body, subject,
29
+ message_timestamp = Time.now)
30
+ end
31
+
32
+ def reply_to_sender_mult_attach(receipt, reply_body,
33
+ subject = nil, sanitize_text = true,
34
+ attachments = nil)
35
+ message = reply(receipt.conversation, receipt.message.sender, reply_body, subject, sanitize_text)
13
36
  attach_files(attachments, message)
14
37
  message.deliver false, sanitize_text
15
38
  end
@@ -34,15 +57,8 @@ module Mailboxer
34
57
  ).build
35
58
  end
36
59
 
37
- def connect_message_to_message_attachments
38
- Mailboxer::Message.class_eval do
39
- has_many :message_attachments
40
- attr_accessible :message_attachments
41
- end
42
- end
43
-
44
60
  def attach_files(attachments, message)
45
- return unless attachments.present?
61
+ return if attachments.blank?
46
62
  attachments.each do |m|
47
63
  message.message_attachments << MessageAttachment.new(file: m[:file])
48
64
  end
@@ -1,3 +1,3 @@
1
1
  module MailboxerMultiAttach
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -14,7 +14,7 @@
14
14
  </p>
15
15
  </blockquote>
16
16
  <p>
17
- Visit <%= link_to root_url, root_url %> and go to your inbox for more info.
17
+ Visit root_url and go to your inbox for more info.
18
18
  </p>
19
19
  </body>
20
20
  </html>
@@ -7,4 +7,4 @@ You have received a new reply:
7
7
  <%= @message.body.html_safe? ? @message.body : strip_tags(@message.body) %>
8
8
  -----------------------------------------------
9
9
 
10
- Visit <%= root_url %> and go to your inbox for more info.
10
+ Visit root_url and go to your inbox for more info.
Binary file