mailboxer 0.4.0 → 0.4.1

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.
@@ -28,12 +28,6 @@ class Message < Notification
28
28
  msg_receipt.receiver = r
29
29
  msg_receipt.mailbox_type = "inbox"
30
30
  temp_receipts << msg_receipt
31
- #Should send an email?
32
- if Mailboxer.uses_emails and r.send(Mailboxer.should_email_method,self)
33
- unless r.send(Mailboxer.email_method).blank?
34
- MessageMailer.send_email(self,r).deliver
35
- end
36
- end
37
31
  end
38
32
  #Sender receipt
39
33
  sender_receipt = Receipt.new
@@ -46,6 +40,14 @@ class Message < Notification
46
40
  temp_receipts.each(&:valid?)
47
41
  if temp_receipts.all? { |t| t.errors.empty? }
48
42
  temp_receipts.each(&:save!) #Save receipts
43
+ self.recipients.each do |r|
44
+ #Should send an email?
45
+ if Mailboxer.uses_emails and r.send(Mailboxer.should_email_method,self)
46
+ unless r.send(Mailboxer.email_method).blank?
47
+ MessageMailer.send_email(self,r).deliver
48
+ end
49
+ end
50
+ end
49
51
  if reply
50
52
  self.conversation.update_attribute(:updated_at, Time.now)
51
53
  end
@@ -42,16 +42,18 @@ class Notification < ActiveRecord::Base
42
42
  msg_receipt.read = false
43
43
  msg_receipt.receiver = r
44
44
  temp_receipts << msg_receipt
45
- #Should send an email?
46
- if Mailboxer.uses_emails and r.send(Mailboxer.should_email_method,self)
47
- unless r.send(Mailboxer.email_method).blank?
48
- NotificationMailer.send_email(self,r).deliver
49
- end
50
- end
51
45
  end
52
46
  temp_receipts.each(&:valid?)
53
47
  if temp_receipts.all? { |t| t.errors.empty? }
54
48
  temp_receipts.each(&:save!) #Save receipts
49
+ self.recipients.each do |r|
50
+ #Should send an email?
51
+ if Mailboxer.uses_emails and r.send(Mailboxer.should_email_method,self)
52
+ unless r.send(Mailboxer.email_method).blank?
53
+ NotificationMailer.send_email(self,r).deliver
54
+ end
55
+ end
56
+ end
55
57
  self.recipients=nil
56
58
  end
57
59
  return temp_receipts if temp_receipts.size > 1
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "mailboxer"
3
- s.version = "0.4.0"
3
+ s.version = "0.4.1"
4
4
  s.authors = ["Eduardo Casanova Cuesta"]
5
5
  s.summary = "Messaging system for rails apps."
6
6
  s.description = "A Rails engine that allows any model to act as messageable, allowing it to exchange messages " +
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailboxer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eduardo Casanova Cuesta