mailboxer_multi_attach 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/app/models/messageable.rb +27 -2
- data/lib/mailboxer_multi_attach/version.rb +1 -1
- data/spec/1.mp4 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +8636 -0
- data/spec/dummy/public/uploads/1.mp4 +0 -0
- data/spec/dummy/public/uploads/tmp/1448392397-96812-3254/testfile.txt +1 -0
- data/spec/dummy/public/uploads/tmp/1448394935-96812-8049/testfile.txt +1 -0
- data/spec/integration/message_and_attachment_spec.rb +34 -0
- data/spec/models/messageable_spec.rb +4 -5
- metadata +12 -4
- data/spec/models/message_attachment_spec.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef3106e52d76d534f6eac1614f300cec4c4bca1f
|
4
|
+
data.tar.gz: 16b6ca721f584c391c9ed39e9b688aff23a39820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef865ed49c4d3bd2c5606dcd879cb7a19fc113011c01b96cd7afc1b95f2de0c4f5ced0a4af058cdc86e4f0311a6de63e451223c6706ee94bd7569effe35798a1
|
7
|
+
data.tar.gz: a2d6a647437faa47e557c8c6fc74934198bd24938e3b4981dadc8d391abfc6f8f88202b378b2e770ec3a806b99ca1c009faf4bd22114965cb9a0bd413340dce8
|
data/README.md
CHANGED
@@ -4,6 +4,7 @@ This project rocks and uses MIT-LICENSE.
|
|
4
4
|
|
5
5
|
## Install
|
6
6
|
|
7
|
+
Project is for Rails 3.2.2 at the moment!
|
7
8
|
Add to your gemfile and run the following
|
8
9
|
|
9
10
|
rails g mailboxer_multi_attach:install
|
@@ -11,7 +12,14 @@ Add to your gemfile and run the following
|
|
11
12
|
|
12
13
|
## Usage
|
13
14
|
|
14
|
-
On any `messageable` object you utilize `send_message_mult_attach`
|
15
|
+
On any `messageable` object you utilize `send_message_mult_attach`. The following works where the entity has the `messageable` reference on its model.
|
16
|
+
|
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)
|
19
|
+
|
20
|
+
You can also not pass in attachments like the following.
|
21
|
+
|
22
|
+
entity1.send_message_mult_attach(entity2, "Body", "Subject", true)
|
15
23
|
|
16
24
|
## TODO
|
17
25
|
- reply_to method for conversations
|
data/app/models/messageable.rb
CHANGED
@@ -24,11 +24,36 @@ module Mailboxer
|
|
24
24
|
attr_accessible :message_attachments
|
25
25
|
end
|
26
26
|
|
27
|
-
attachments.
|
28
|
-
|
27
|
+
if attachments.present?
|
28
|
+
attachments.each do |m|
|
29
|
+
message.message_attachments << MessageAttachment.new(file: m[:file])
|
30
|
+
end
|
29
31
|
end
|
30
32
|
message.deliver false, sanitize_text
|
31
33
|
end
|
34
|
+
|
35
|
+
def reply_to_convo_mult_attach(convo, convo_body, subject, sanitize_text=true, attachment=nil)
|
36
|
+
if should_untrash && mailbox.is_trashed?(conversation)
|
37
|
+
mailbox.receipts_for(conversation).untrash
|
38
|
+
mailbox.receipts_for(conversation).mark_as_not_deleted
|
39
|
+
end
|
40
|
+
reply_mult_attach(conversation, conversation.last_message.recipients, reply_body, subject, sanitize_text, attachment)
|
41
|
+
end
|
42
|
+
|
43
|
+
def reply_mult_attach(conversation, recipients, reply_body, subject=nil, sanitize_text=true, attachment=nil)
|
44
|
+
subject ||= "#{conversation.subject}"
|
45
|
+
response = Mailboxer::MessageBuilder.new({
|
46
|
+
:sender => self,
|
47
|
+
:conversation => recipients,
|
48
|
+
:body => reply_body,
|
49
|
+
:subject => subject
|
50
|
+
}).build
|
51
|
+
|
52
|
+
#TODO: handle attachments
|
53
|
+
|
54
|
+
response.recipients.delete(self)
|
55
|
+
response.deliver true, sanitize_text
|
56
|
+
end
|
32
57
|
end
|
33
58
|
end
|
34
59
|
end
|
data/spec/1.mp4
ADDED
Binary file
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|