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 +4 -4
- data/README.md +3 -2
- data/app/models/messageable.rb +25 -9
- data/lib/mailboxer_multi_attach/version.rb +1 -1
- data/spec/dummy/app/views/mailboxer/message_mailer/reply_message_email.html.erb +1 -1
- data/spec/dummy/app/views/mailboxer/message_mailer/reply_message_email.text.erb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +23177 -0
- data/spec/integration/message_and_attachment_spec.rb +59 -26
- data/spec/models/messageable_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a0763dd1759a15f9f9b73b9e69e32aed1f51e74
|
4
|
+
data.tar.gz: 6c99650728ab7ba73e276c2b6228ba54c34d460b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
|
data/app/models/messageable.rb
CHANGED
@@ -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
|
-
|
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
|
61
|
+
return if attachments.blank?
|
46
62
|
attachments.each do |m|
|
47
63
|
message.message_attachments << MessageAttachment.new(file: m[:file])
|
48
64
|
end
|
@@ -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
|
10
|
+
Visit root_url and go to your inbox for more info.
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|