mailboxer 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -91,6 +91,10 @@ class MailboxerConversation < ActiveRecord::Base
91
91
  return MailboxerMessage.conversation(self).count
92
92
  end
93
93
 
94
+ def is_participant?(participant)
95
+ return false if participant.nil?
96
+ return MailboxerMail.conversation(self).receiver(participant).count != 0
97
+ end
94
98
  # protected
95
99
  # #[empty method]
96
100
  # #
@@ -36,7 +36,7 @@ class MailboxerMessage < ActiveRecord::Base
36
36
  self.mailboxer_mails.each do |mail|
37
37
  recipients_array << mail.receiver
38
38
  end
39
- return recipients_array
39
+ return recipients_array.uniq
40
40
  end
41
41
 
42
42
  def conversation
@@ -5,9 +5,9 @@ module Mailboxer
5
5
  def self.included(mod)
6
6
  mod.extend(ClassMethods)
7
7
  end
8
-
8
+
9
9
  module ClassMethods
10
-
10
+
11
11
  def acts_as_messageable
12
12
  has_many :mailboxer_messages
13
13
  has_many :mailboxer_mails, :order => 'created_at DESC', :dependent => :delete_all
@@ -15,15 +15,15 @@ module Mailboxer
15
15
  include Mailboxer::Models::Messageable::InstanceMethods
16
16
  end
17
17
  end
18
-
18
+
19
19
  module InstanceMethods
20
-
20
+
21
21
  def mailbox
22
22
  @mailbox = MailboxerMailbox.new(self) if @mailbox.nil?
23
23
  @mailbox.type = :all
24
24
  return @mailbox
25
25
  end
26
-
26
+
27
27
  def send_message(recipients, msg_body, subject = '')
28
28
  convo = MailboxerConversation.create({:subject => subject})
29
29
  message = MailboxerMessage.create({:sender => self, :mailboxer_conversation => convo, :body => msg_body, :subject => subject})
@@ -31,32 +31,27 @@ module Mailboxer
31
31
  message.deliver(:inbox)
32
32
  return mailbox[:sentbox] << message
33
33
  end
34
-
34
+
35
35
  def reply(conversation, recipients, reply_body, subject = nil)
36
36
  return nil if(reply_body.blank?)
37
37
  subject = subject || "RE: #{conversation.subject}"
38
38
  response = MailboxerMessage.create({:sender => self, :mailboxer_conversation => conversation, :body => reply_body, :subject => subject})
39
39
  response.recipients = recipients.is_a?(Array) ? recipients : [recipients]
40
+ response.recipients.delete(self)
40
41
  response.deliver(:inbox)
41
42
  return mailbox[:sentbox] << response
42
43
  end
43
-
44
+
44
45
  def reply_to_sender(mail, reply_body, subject = nil)
45
46
  return reply(mail.mailboxer_conversation, mail.mailboxer_message.sender, reply_body, subject)
46
47
  end
47
-
48
+
48
49
  def reply_to_all(mail, reply_body, subject = nil)
49
50
  msg = mail.mailboxer_message
50
51
  recipients = msg.get_recipients
51
- if(msg.sender != self)
52
- recipients.delete(self)
53
- if(!recipients.include?(msg.sender))
54
- recipients << msg.sender
55
- end
56
- end
57
52
  return reply(mail.mailboxer_conversation, recipients, reply_body, subject)
58
53
  end
59
-
54
+
60
55
  def reply_to_conversation(conversation, reply_body, subject = nil)
61
56
  #move conversation to inbox if it is currently in the trash - doesnt make much sense replying to a trashed convo.
62
57
  if(mailbox.is_trashed?(conversation))
@@ -80,7 +75,7 @@ module Mailboxer
80
75
  def unread_mail(mail)
81
76
  return mail.mark_as_unread if mail.receiver == self
82
77
  end
83
-
78
+
84
79
  def read_conversation(conversation, options = {})
85
80
  mails = conversation.mailboxer_mails.receiver(self)
86
81
  mails_clone = mails.clone
data/mailboxer.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "mailboxer"
4
- s.version = "0.0.6"
4
+ s.version = "0.0.7"
5
5
 
6
6
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
7
7
  s.authors = ["Eduardo Casanova Cuesta"]
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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eduardo Casanova Cuesta