mailboxer_multi_attach 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f581bd3e39955398015a6b2c5a93015a4c294ca
4
- data.tar.gz: 9ea3db9d621382d4abef025192690a4b02d0cd73
3
+ metadata.gz: ef3106e52d76d534f6eac1614f300cec4c4bca1f
4
+ data.tar.gz: 16b6ca721f584c391c9ed39e9b688aff23a39820
5
5
  SHA512:
6
- metadata.gz: 0d9ab4401cdb07896af963d4f261d17b16932ac60687d10dc274b2fee5a1ca5705dee415f12ce99243b30022692ea581ab38a78ee0653d7f11a9a484c302ac44
7
- data.tar.gz: 51a988f11239485531b9b480836638303a602157f17ae3283e8fb0d934426a823e956ddba77a8a6e6f6256d69a5a10a9d00b8591941427d8c62365fd790c6b95
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
@@ -24,11 +24,36 @@ module Mailboxer
24
24
  attr_accessible :message_attachments
25
25
  end
26
26
 
27
- attachments.each do |m|
28
- message.message_attachments << MessageAttachment.new(file: m[:file])
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
@@ -1,3 +1,3 @@
1
1
  module MailboxerMultiAttach
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/1.mp4 ADDED
Binary file
Binary file