curationexperts-mailboxer 0.10.3.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +10 -0
  5. data/.yardopts +2 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE.txt +20 -0
  8. data/README.md +273 -0
  9. data/Rakefile +7 -0
  10. data/app/mailers/message_mailer.rb +37 -0
  11. data/app/mailers/notification_mailer.rb +21 -0
  12. data/app/models/conversation.rb +143 -0
  13. data/app/models/mailbox.rb +121 -0
  14. data/app/models/message.rb +66 -0
  15. data/app/models/notification.rb +184 -0
  16. data/app/models/receipt.rb +151 -0
  17. data/app/uploaders/attachment_uploader.rb +3 -0
  18. data/app/views/message_mailer/new_message_email.html.erb +20 -0
  19. data/app/views/message_mailer/new_message_email.text.erb +10 -0
  20. data/app/views/message_mailer/reply_message_email.html.erb +20 -0
  21. data/app/views/message_mailer/reply_message_email.text.erb +10 -0
  22. data/app/views/notification_mailer/new_notification_email.html.erb +20 -0
  23. data/app/views/notification_mailer/new_notification_email.text.erb +10 -0
  24. data/config/locales/en.yml +7 -0
  25. data/db/migrate/20110511145103_create_mailboxer.rb +61 -0
  26. data/db/migrate/20110719110700_add_notified_object.rb +17 -0
  27. data/db/migrate/20110912163911_add_notification_code.rb +13 -0
  28. data/db/migrate/20111204163911_add_attachments.rb +9 -0
  29. data/db/migrate/20120813110712_rename_receipts_read.rb +9 -0
  30. data/db/migrate/20130305144212_add_global_notification_support.rb +9 -0
  31. data/lib/generators/mailboxer/install_generator.rb +35 -0
  32. data/lib/generators/mailboxer/templates/initializer.rb +17 -0
  33. data/lib/generators/mailboxer/views_generator.rb +9 -0
  34. data/lib/mailboxer.rb +31 -0
  35. data/lib/mailboxer/concerns/configurable_mailer.rb +13 -0
  36. data/lib/mailboxer/engine.rb +18 -0
  37. data/lib/mailboxer/models/messageable.rb +208 -0
  38. data/mailboxer.gemspec +47 -0
  39. data/spec/dummy/.gitignore +5 -0
  40. data/spec/dummy/Gemfile +33 -0
  41. data/spec/dummy/Rakefile +7 -0
  42. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  43. data/spec/dummy/app/controllers/home_controller.rb +4 -0
  44. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  45. data/spec/dummy/app/mailers/.gitkeep +0 -0
  46. data/spec/dummy/app/models/.gitkeep +0 -0
  47. data/spec/dummy/app/models/cylon.rb +7 -0
  48. data/spec/dummy/app/models/duck.rb +11 -0
  49. data/spec/dummy/app/models/user.rb +6 -0
  50. data/spec/dummy/app/views/home/index.html.haml +7 -0
  51. data/spec/dummy/app/views/layouts/application.html.haml +11 -0
  52. data/spec/dummy/config.ru +4 -0
  53. data/spec/dummy/config/application.rb +42 -0
  54. data/spec/dummy/config/boot.rb +10 -0
  55. data/spec/dummy/config/database.yml +24 -0
  56. data/spec/dummy/config/environment.rb +5 -0
  57. data/spec/dummy/config/environments/development.rb +26 -0
  58. data/spec/dummy/config/environments/production.rb +49 -0
  59. data/spec/dummy/config/environments/test.rb +33 -0
  60. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  61. data/spec/dummy/config/initializers/inflections.rb +10 -0
  62. data/spec/dummy/config/initializers/mailboxer.rb +17 -0
  63. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  64. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  65. data/spec/dummy/config/initializers/session_store.rb +8 -0
  66. data/spec/dummy/config/locales/en.yml +5 -0
  67. data/spec/dummy/config/routes.rb +58 -0
  68. data/spec/dummy/config/sunspot.yml +17 -0
  69. data/spec/dummy/db/migrate/20110228120600_create_users.rb +14 -0
  70. data/spec/dummy/db/migrate/20110306002940_create_ducks.rb +14 -0
  71. data/spec/dummy/db/migrate/20110306015107_create_cylons.rb +14 -0
  72. data/spec/dummy/db/migrate/20120305103200_create_mailboxer.rb +61 -0
  73. data/spec/dummy/db/migrate/20120305103201_add_notified_object.rb +17 -0
  74. data/spec/dummy/db/migrate/20120305103202_add_notification_code.rb +13 -0
  75. data/spec/dummy/db/migrate/20120305103203_add_attachments.rb +5 -0
  76. data/spec/dummy/db/migrate/20120813110712_rename_receipts_read.rb +9 -0
  77. data/spec/dummy/db/migrate/20130305144212_add_global_notification_support.rb +11 -0
  78. data/spec/dummy/db/schema.rb +74 -0
  79. data/spec/dummy/public/404.html +26 -0
  80. data/spec/dummy/public/422.html +26 -0
  81. data/spec/dummy/public/500.html +26 -0
  82. data/spec/dummy/public/favicon.ico +0 -0
  83. data/spec/dummy/public/index.html +239 -0
  84. data/spec/dummy/public/robots.txt +5 -0
  85. data/spec/dummy/public/uploads/testfile.txt +1 -0
  86. data/spec/dummy/script/rails +6 -0
  87. data/spec/factories/cylon.rb +10 -0
  88. data/spec/factories/duck.rb +10 -0
  89. data/spec/factories/user.rb +10 -0
  90. data/spec/integration/message_and_receipt_spec.rb +903 -0
  91. data/spec/integration/navigation_spec.rb +9 -0
  92. data/spec/mailboxer/concerns/configurable_mailer_spec.rb +27 -0
  93. data/spec/mailboxer_spec.rb +7 -0
  94. data/spec/mailers/message_mailer_spec.rb +110 -0
  95. data/spec/mailers/notification_mailer_spec.rb +61 -0
  96. data/spec/models/conversation_spec.rb +101 -0
  97. data/spec/models/mailbox_spec.rb +124 -0
  98. data/spec/models/mailboxer_models_messageable_spec.rb +315 -0
  99. data/spec/models/message_spec.rb +24 -0
  100. data/spec/models/notification_spec.rb +200 -0
  101. data/spec/models/receipt_spec.rb +44 -0
  102. data/spec/spec_helper.rb +36 -0
  103. data/spec/testfile.txt +1 -0
  104. metadata +263 -0
@@ -0,0 +1,121 @@
1
+ class Mailbox
2
+ attr_accessor :type
3
+ attr_reader :messageable
4
+ #Initializer method
5
+ def initialize(messageable)
6
+ @messageable = messageable
7
+ end
8
+
9
+ #Returns the notifications for the messageable
10
+ def notifications(options = {})
11
+ #:type => nil is a hack not to give Messages as Notifications
12
+ notifs = Notification.recipient(@messageable).where(:type => nil).order("notifications.created_at DESC")
13
+ if (options[:read].present? and options[:read]==false) or (options[:unread].present? and options[:unread]==true)
14
+ notifs = notifs.unread
15
+ end
16
+ return notifs
17
+ end
18
+
19
+ #Returns the conversations for the messageable
20
+ #
21
+ #Options
22
+ #
23
+ #* :mailbox_type
24
+ # * "inbox"
25
+ # * "sentbox"
26
+ # * "trash"
27
+ #
28
+ #* :read=false
29
+ #* :unread=true
30
+ #
31
+ def conversations(options = {})
32
+ conv = Conversation.participant(@messageable)
33
+
34
+ if options[:mailbox_type].present?
35
+ case options[:mailbox_type]
36
+ when 'inbox'
37
+ conv = Conversation.inbox(@messageable)
38
+ when 'sentbox'
39
+ conv = Conversation.sentbox(@messageable)
40
+ when 'trash'
41
+ conv = Conversation.trash(@messageable)
42
+ end
43
+ end
44
+
45
+ if (options.has_key?(:read) && options[:read]==false) || (options.has_key?(:unread) && options[:unread]==true)
46
+ conv = conv.unread(@messageable)
47
+ end
48
+
49
+ return conv
50
+ end
51
+
52
+ #Returns the conversations in the inbox of messageable
53
+ #
54
+ #Same as conversations({:mailbox_type => 'inbox'})
55
+ def inbox(options={})
56
+ options = options.merge(:mailbox_type => 'inbox')
57
+ return self.conversations(options)
58
+ end
59
+
60
+ #Returns the conversations in the sentbox of messageable
61
+ #
62
+ #Same as conversations({:mailbox_type => 'sentbox'})
63
+ def sentbox(options={})
64
+ options = options.merge(:mailbox_type => 'sentbox')
65
+ return self.conversations(options)
66
+ end
67
+
68
+ #Returns the conversations in the trash of messageable
69
+ #
70
+ #Same as conversations({:mailbox_type => 'trash'})
71
+ def trash(options={})
72
+ options = options.merge(:mailbox_type => 'trash')
73
+ return self.conversations(options)
74
+ end
75
+
76
+ #Returns all the receipts of messageable, from Messages and Notifications
77
+ def receipts(options = {})
78
+ return Receipt.where(options).recipient(@messageable)
79
+ end
80
+
81
+ #Deletes all the messages in the trash of messageable. NOT IMPLEMENTED.
82
+ def empty_trash(options = {})
83
+ #TODO
84
+ return false
85
+ end
86
+
87
+ #Returns if messageable is a participant of conversation
88
+ def has_conversation?(conversation)
89
+ return conversation.is_participant?(@messageable)
90
+ end
91
+
92
+ #Returns true if messageable has at least one trashed message of the conversation
93
+ def is_trashed?(conversation)
94
+ return conversation.is_trashed?(@messageable)
95
+ end
96
+
97
+ #Returns true if messageable has trashed all the messages of the conversation
98
+ def is_completely_trashed?(conversation)
99
+ return conversation.is_completely_trashed?(@messageable)
100
+ end
101
+
102
+ #Returns the receipts of object for messageable as a ActiveRecord::Relation
103
+ #
104
+ #Object can be:
105
+ #* A Message
106
+ #* A Notification
107
+ #* A Conversation
108
+ #
109
+ #If object isn't one of the above, a nil will be returned
110
+ def receipts_for(object)
111
+ case object
112
+ when Message, Notification
113
+ return object.receipt_for(@messageable)
114
+ when Conversation
115
+ return object.receipts_for(@messageable)
116
+ else
117
+ return nil
118
+ end
119
+ end
120
+
121
+ end
@@ -0,0 +1,66 @@
1
+ class Message < Notification
2
+ attr_accessible :attachment if Rails::VERSION::MAJOR == 3
3
+
4
+ belongs_to :conversation, :validate => true, :autosave => true
5
+ validates_presence_of :sender
6
+
7
+ class_attribute :on_deliver_callback
8
+ protected :on_deliver_callback
9
+ scope :conversation, lambda { |conversation|
10
+ where(:conversation_id => conversation.id)
11
+ }
12
+
13
+ mount_uploader :attachment, AttachmentUploader
14
+
15
+ include Concerns::ConfigurableMailer
16
+
17
+ class << self
18
+ #Sets the on deliver callback method.
19
+ def on_deliver(callback_method)
20
+ self.on_deliver_callback = callback_method
21
+ end
22
+ end
23
+
24
+ #Delivers a Message. USE NOT RECOMENDED.
25
+ #Use Mailboxer::Models::Message.send_message instead.
26
+ def deliver(reply = false, should_clean = true)
27
+ self.clean if should_clean
28
+ temp_receipts = Array.new
29
+ #Receiver receipts
30
+ self.recipients.each do |r|
31
+ msg_receipt = Receipt.new
32
+ msg_receipt.notification = self
33
+ msg_receipt.is_read = false
34
+ msg_receipt.receiver = r
35
+ msg_receipt.mailbox_type = "inbox"
36
+ temp_receipts << msg_receipt
37
+ end
38
+ #Sender receipt
39
+ sender_receipt = Receipt.new
40
+ sender_receipt.notification = self
41
+ sender_receipt.is_read = true
42
+ sender_receipt.receiver = self.sender
43
+ sender_receipt.mailbox_type = "sentbox"
44
+ temp_receipts << sender_receipt
45
+
46
+ temp_receipts.each(&:valid?)
47
+ if temp_receipts.all? { |t| t.errors.empty? }
48
+ temp_receipts.each(&:save!) #Save receipts
49
+ self.recipients.each do |r|
50
+ #Should send an email?
51
+ if Mailboxer.uses_emails
52
+ email_to = r.send(Mailboxer.email_method,self)
53
+ unless email_to.blank?
54
+ get_mailer.send_email(self,r).deliver
55
+ end
56
+ end
57
+ end
58
+ if reply
59
+ self.conversation.touch
60
+ end
61
+ self.recipients=nil
62
+ self.on_deliver_callback.call(self) unless self.on_deliver_callback.nil?
63
+ end
64
+ return sender_receipt
65
+ end
66
+ end
@@ -0,0 +1,184 @@
1
+ class Notification < ActiveRecord::Base
2
+ attr_accessor :recipients
3
+ attr_accessible :body, :subject, :global, :expires if Rails::VERSION::MAJOR == 3
4
+
5
+ belongs_to :sender, :polymorphic => :true
6
+ belongs_to :notified_object, :polymorphic => :true
7
+ validates_presence_of :subject, :body
8
+ has_many :receipts, :dependent => :destroy
9
+
10
+ scope :recipient, lambda { |recipient|
11
+ joins(:receipts).where('receipts.receiver_id' => recipient.id,'receipts.receiver_type' => recipient.class.to_s)
12
+ }
13
+ scope :with_object, lambda { |obj|
14
+ where('notified_object_id' => obj.id,'notified_object_type' => obj.class.to_s)
15
+ }
16
+ scope :not_trashed, lambda {
17
+ joins(:receipts).where('receipts.trashed' => false)
18
+ }
19
+ scope :unread, lambda {
20
+ joins(:receipts).where('receipts.is_read' => false)
21
+ }
22
+ scope :global, lambda { where(:global => true) }
23
+ scope :expired, lambda { where("notifications.expires < ?", Time.now) }
24
+ scope :unexpired, lambda {
25
+ where("notifications.expires is NULL OR notifications.expires > ?", Time.now)
26
+ }
27
+
28
+ include Concerns::ConfigurableMailer
29
+
30
+ class << self
31
+ #Sends a Notification to all the recipients
32
+ def notify_all(recipients,subject,body,obj = nil,sanitize_text = true,notification_code=nil)
33
+ notification = Notification.new({:body => body, :subject => subject})
34
+ notification.recipients = recipients.respond_to?(:each) ? recipients : [recipients]
35
+ notification.recipients = notification.recipients.uniq if recipients.respond_to?(:uniq)
36
+ notification.notified_object = obj if obj.present?
37
+ notification.notification_code = notification_code if notification_code.present?
38
+ return notification.deliver sanitize_text
39
+ end
40
+
41
+ #Takes a +Receipt+ or an +Array+ of them and returns +true+ if the delivery was
42
+ #successful or +false+ if some error raised
43
+ def successful_delivery? receipts
44
+ case receipts
45
+ when Receipt
46
+ receipts.valid?
47
+ return receipts.errors.empty?
48
+ when Array
49
+ receipts.each(&:valid?)
50
+ return receipts.all? { |t| t.errors.empty? }
51
+ else
52
+ return false
53
+ end
54
+ end
55
+ end
56
+
57
+ def expired?
58
+ return self.expires.present? && (self.expires < Time.now)
59
+ end
60
+
61
+ def expire!
62
+ unless self.expired?
63
+ self.expire
64
+ self.save
65
+ end
66
+ end
67
+
68
+ def expire
69
+ unless self.expired?
70
+ self.expires = Time.now - 1.second
71
+ end
72
+ end
73
+
74
+ #Delivers a Notification. USE NOT RECOMENDED.
75
+ #Use Mailboxer::Models::Message.notify and Notification.notify_all instead.
76
+ def deliver(should_clean = true)
77
+ self.clean if should_clean
78
+ temp_receipts = Array.new
79
+ #Receiver receipts
80
+ self.recipients.each do |r|
81
+ msg_receipt = Receipt.new
82
+ msg_receipt.notification = self
83
+ msg_receipt.is_read = false
84
+ msg_receipt.receiver = r
85
+ temp_receipts << msg_receipt
86
+ end
87
+ temp_receipts.each(&:valid?)
88
+ if temp_receipts.all? { |t| t.errors.empty? }
89
+ temp_receipts.each(&:save!) #Save receipts
90
+ self.recipients.each do |r|
91
+ #Should send an email?
92
+ if Mailboxer.uses_emails
93
+ email_to = r.send(Mailboxer.email_method,self)
94
+ unless email_to.blank?
95
+ get_mailer.send_email(self,r).deliver
96
+ end
97
+ end
98
+ end
99
+ self.recipients=nil
100
+ end
101
+ return temp_receipts if temp_receipts.size > 1
102
+ return temp_receipts.first
103
+ end
104
+
105
+ #Returns the recipients of the Notification
106
+ def recipients
107
+ if @recipients.blank?
108
+ recipients_array = Array.new
109
+ self.receipts.each do |receipt|
110
+ recipients_array << receipt.receiver
111
+ end
112
+ return recipients_array
113
+ end
114
+ return @recipients
115
+ end
116
+
117
+ #Returns the receipt for the participant
118
+ def receipt_for(participant)
119
+ return Receipt.notification(self).recipient(participant)
120
+ end
121
+
122
+ #Returns the receipt for the participant. Alias for receipt_for(participant)
123
+ def receipts_for(participant)
124
+ return receipt_for(participant)
125
+ end
126
+
127
+ #Returns if the participant have read the Notification
128
+ def is_unread?(participant)
129
+ return false if participant.nil?
130
+ return !self.receipt_for(participant).first.is_read
131
+ end
132
+
133
+ def is_read?(participant)
134
+ !self.is_unread?(participant)
135
+ end
136
+
137
+ #Returns if the participant have trashed the Notification
138
+ def is_trashed?(participant)
139
+ return false if participant.nil?
140
+ return self.receipt_for(participant).first.trashed
141
+ end
142
+
143
+ #Mark the notification as read
144
+ def mark_as_read(participant)
145
+ return if participant.nil?
146
+ return self.receipt_for(participant).mark_as_read
147
+ end
148
+
149
+ #Mark the notification as unread
150
+ def mark_as_unread(participant)
151
+ return if participant.nil?
152
+ return self.receipt_for(participant).mark_as_unread
153
+ end
154
+
155
+ #Move the notification to the trash
156
+ def move_to_trash(participant)
157
+ return if participant.nil?
158
+ return self.receipt_for(participant).move_to_trash
159
+ end
160
+
161
+ #Takes the notification out of the trash
162
+ def untrash(participant)
163
+ return if participant.nil?
164
+ return self.receipt_for(participant).untrash
165
+ end
166
+
167
+
168
+ include ActionView::Helpers::SanitizeHelper
169
+
170
+ #Sanitizes the body and subject
171
+ def clean
172
+ unless self.subject.nil?
173
+ self.subject = sanitize self.subject
174
+ end
175
+ self.body = sanitize self.body
176
+ end
177
+
178
+ #Returns notified_object. DEPRECATED
179
+ def object
180
+ warn "DEPRECATION WARNING: use 'notify_object' instead of 'object' to get the object associated with the Notification"
181
+ notified_object
182
+ end
183
+
184
+ end
@@ -0,0 +1,151 @@
1
+ class Receipt < ActiveRecord::Base
2
+ belongs_to :notification, :validate => true, :autosave => true
3
+ belongs_to :receiver, :polymorphic => :true
4
+ belongs_to :message, :foreign_key => "notification_id"
5
+
6
+ validates_presence_of :receiver
7
+ attr_accessible :trashed, :is_read if Rails::VERSION::MAJOR == 3
8
+
9
+ scope :recipient, lambda { |recipient|
10
+ where(:receiver_id => recipient.id,:receiver_type => recipient.class.base_class.to_s)
11
+ }
12
+ #Notifications Scope checks type to be nil, not Notification because of STI behaviour
13
+ #with the primary class (no type is saved)
14
+ scope :notifications_receipts, lambda { joins(:notification).where('notifications.type' => nil) }
15
+ scope :messages_receipts, lambda { joins(:notification).where('notifications.type' => Message.to_s) }
16
+ scope :notification, lambda { |notification|
17
+ where(:notification_id => notification.id)
18
+ }
19
+ scope :conversation, lambda { |conversation|
20
+ joins(:message).where('notifications.conversation_id' => conversation.id)
21
+ }
22
+ scope :sentbox, lambda { where(:mailbox_type => "sentbox") }
23
+ scope :inbox, lambda { where(:mailbox_type => "inbox") }
24
+ scope :trash, lambda { where(:trashed => true) }
25
+ scope :not_trash, lambda { where(:trashed => false) }
26
+ scope :is_read, lambda { where(:is_read => true) }
27
+ scope :is_unread, lambda { where(:is_read => false) }
28
+
29
+ after_validation :remove_duplicate_errors
30
+ class << self
31
+ #Marks all the receipts from the relation as read
32
+ def mark_as_read(options={})
33
+ update_receipts({:is_read => true}, options)
34
+ end
35
+
36
+ #Marks all the receipts from the relation as unread
37
+ def mark_as_unread(options={})
38
+ update_receipts({:is_read => false}, options)
39
+ end
40
+
41
+ #Marks all the receipts from the relation as trashed
42
+ def move_to_trash(options={})
43
+ update_receipts({:trashed => true}, options)
44
+ end
45
+
46
+ #Marks all the receipts from the relation as not trashed
47
+ def untrash(options={})
48
+ update_receipts({:trashed => false}, options)
49
+ end
50
+
51
+ #Moves all the receipts from the relation to inbox
52
+ def move_to_inbox(options={})
53
+ update_receipts({:mailbox_type => :inbox, :trashed => false}, options)
54
+ end
55
+
56
+ #Moves all the receipts from the relation to sentbox
57
+ def move_to_sentbox(options={})
58
+ update_receipts({:mailbox_type => :sentbox, :trashed => false}, options)
59
+ end
60
+
61
+ #This methods helps to do a update_all with table joins, not currently supported by rails.
62
+ #Acording to the github ticket https://github.com/rails/rails/issues/522 it should be
63
+ #supported with 3.2.
64
+ def update_receipts(updates,options={})
65
+ ids = Array.new
66
+ where(options).each do |rcp|
67
+ ids << rcp.id
68
+ end
69
+ return if ids.empty?
70
+ conditions = [""].concat(ids)
71
+ condition = "id = ? "
72
+ ids.drop(1).each do
73
+ condition << "OR id = ? "
74
+ end
75
+ conditions[0] = condition
76
+ Receipt.except(:where).except(:joins).where(conditions).update_all(updates)
77
+ end
78
+ end
79
+
80
+ #Marks the receipt as read
81
+ def mark_as_read
82
+ update_attributes(:is_read => true)
83
+ end
84
+
85
+ #Marks the receipt as unread
86
+ def mark_as_unread
87
+ update_attributes(:is_read => false)
88
+ end
89
+
90
+ #Marks the receipt as trashed
91
+ def move_to_trash
92
+ update_attributes(:trashed => true)
93
+ end
94
+
95
+ #Marks the receipt as not trashed
96
+ def untrash
97
+ update_attributes(:trashed => false)
98
+ end
99
+
100
+ #Moves the receipt to inbox
101
+ def move_to_inbox
102
+ update_attributes(:mailbox_type => :inbox, :trashed => false)
103
+ end
104
+
105
+ #Moves the receipt to sentbox
106
+ def move_to_sentbox
107
+ update_attributes(:mailbox_type => :sentbox, :trashed => false)
108
+ end
109
+
110
+ #Returns the conversation associated to the receipt if the notification is a Message
111
+ def conversation
112
+ return message.conversation if message.is_a? Message
113
+ return nil
114
+ end
115
+
116
+ #Returns if the participant have read the Notification
117
+ def is_unread?
118
+ return !self.is_read
119
+ end
120
+
121
+ #Returns if the participant have trashed the Notification
122
+ def is_trashed?
123
+ return self.trashed
124
+ end
125
+
126
+
127
+ protected
128
+
129
+ #Removes the duplicate error about not present subject from Conversation if it has been already
130
+ #raised by Message
131
+ def remove_duplicate_errors
132
+ if self.errors["notification.conversation.subject"].present? and self.errors["notification.subject"].present?
133
+ self.errors["notification.conversation.subject"].each do |msg|
134
+ self.errors["notification.conversation.subject"].delete(msg)
135
+ end
136
+ end
137
+ end
138
+
139
+ if Mailboxer.search_enabled
140
+ searchable do
141
+ text :subject, :boost => 5 do
142
+ message.subject if message
143
+ end
144
+ text :body do
145
+ message.body if message
146
+ end
147
+ integer :receiver_id
148
+ end
149
+ end
150
+
151
+ end