mailboxer 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/mailboxer_conversation.rb +5 -5
- data/lib/generators/mailboxer/templates/migration.rb +6 -0
- data/lib/mailboxer/models/messageable.rb +1 -0
- data/mailboxer.gemspec +2 -2
- data/spec/dummy/db/migrate/{20110303122122_create_mailboxer.rb → 20110321231559_create_mailboxer.rb} +6 -0
- data/spec/dummy/db/schema.rb +6 -26
- metadata +5 -5
@@ -4,19 +4,19 @@ class MailboxerConversation < ActiveRecord::Base
|
|
4
4
|
has_many :mailboxer_mails, :through => :mailboxer_messages
|
5
5
|
# before_create :clean
|
6
6
|
scope :participant, lambda {|participant|
|
7
|
-
joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s)
|
7
|
+
joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s).order("mailboxer_conversations.updated_at DESC")
|
8
8
|
}
|
9
9
|
scope :inbox, lambda {|participant|
|
10
|
-
joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s, 'mailboxer_mails.mailbox_type' => 'inbox','mailboxer_mails.trashed' => false)
|
10
|
+
joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s, 'mailboxer_mails.mailbox_type' => 'inbox','mailboxer_mails.trashed' => false).order("mailboxer_conversations.updated_at DESC")
|
11
11
|
}
|
12
12
|
scope :sentbox, lambda {|participant|
|
13
|
-
joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s, 'mailboxer_mails.mailbox_type' => 'sentbox','mailboxer_mails.trashed' => false)
|
13
|
+
joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s, 'mailboxer_mails.mailbox_type' => 'sentbox','mailboxer_mails.trashed' => false).order("mailboxer_conversations.updated_at DESC")
|
14
14
|
}
|
15
15
|
scope :trash, lambda {|participant|
|
16
|
-
joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s,'mailboxer_mails.trashed' => true)
|
16
|
+
joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s,'mailboxer_mails.trashed' => true).order("mailboxer_conversations.updated_at DESC")
|
17
17
|
}
|
18
18
|
scope :unread, lambda {|participant|
|
19
|
-
joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s,'mailboxer_mails.read' => false)
|
19
|
+
joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s,'mailboxer_mails.read' => false).order("mailboxer_conversations.updated_at DESC")
|
20
20
|
}
|
21
21
|
|
22
22
|
class << self
|
@@ -3,14 +3,17 @@ class CreateMailboxer < ActiveRecord::Migration
|
|
3
3
|
create_table :mailboxer_conversations do |t|
|
4
4
|
t.column :subject, :string, :default => ""
|
5
5
|
t.column :created_at, :datetime, :null => false
|
6
|
+
t.column :updated_at, :datetime, :null => false
|
6
7
|
end
|
7
8
|
create_table :mailboxer_mails do |t|
|
8
9
|
t.references :receiver, :polymorphic => true
|
9
10
|
t.column :mailboxer_message_id, :integer, :null => false
|
10
11
|
t.column :read, :boolean, :default => false
|
11
12
|
t.column :trashed, :boolean, :default => false
|
13
|
+
t.column :deleted, :boolean, :default => false
|
12
14
|
t.column :mailbox_type, :string, :limit => 25
|
13
15
|
t.column :created_at, :datetime, :null => false
|
16
|
+
t.column :updated_at, :datetime, :null => false
|
14
17
|
end
|
15
18
|
create_table :mailboxer_messages do |t|
|
16
19
|
t.column :body, :text
|
@@ -19,6 +22,9 @@ class CreateMailboxer < ActiveRecord::Migration
|
|
19
22
|
t.references :sender, :polymorphic => true
|
20
23
|
t.column :mailboxer_conversation_id, :integer
|
21
24
|
t.column :sent, :boolean, :default => false
|
25
|
+
t.column :draft, :boolean, :default => false
|
26
|
+
t.column :system, :boolean, :default => false
|
27
|
+
t.column :updated_at, :datetime, :null => false
|
22
28
|
t.column :created_at, :datetime, :null => false
|
23
29
|
end
|
24
30
|
end
|
@@ -34,6 +34,7 @@ module Mailboxer
|
|
34
34
|
|
35
35
|
def reply(conversation, recipients, reply_body, subject = nil)
|
36
36
|
return nil if(reply_body.blank?)
|
37
|
+
conversation.update_attribute(:updated_at, Time.now)
|
37
38
|
subject = subject || "RE: #{conversation.subject}"
|
38
39
|
response = MailboxerMessage.create({:sender => self, :mailboxer_conversation => conversation, :body => reply_body, :subject => subject})
|
39
40
|
response.recipients = recipients.is_a?(Array) ? recipients : [recipients]
|
data/mailboxer.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = "mailboxer"
|
4
|
-
s.version = "0.0.
|
4
|
+
s.version = "0.0.8"
|
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"]
|
8
|
-
s.date = %q{2011-03-
|
8
|
+
s.date = %q{2011-03-22}
|
9
9
|
s.description = %q{A Rails engine that allows any model to act as messageable, permitting it interchange messages with any other messageable model. }
|
10
10
|
s.email = %q{ecasanovac@gmail.com}
|
11
11
|
s.extra_rdoc_files = [
|
data/spec/dummy/db/migrate/{20110303122122_create_mailboxer.rb → 20110321231559_create_mailboxer.rb}
RENAMED
@@ -3,14 +3,17 @@ class CreateMailboxer < ActiveRecord::Migration
|
|
3
3
|
create_table :mailboxer_conversations do |t|
|
4
4
|
t.column :subject, :string, :default => ""
|
5
5
|
t.column :created_at, :datetime, :null => false
|
6
|
+
t.column :updated_at, :datetime, :null => false
|
6
7
|
end
|
7
8
|
create_table :mailboxer_mails do |t|
|
8
9
|
t.references :receiver, :polymorphic => true
|
9
10
|
t.column :mailboxer_message_id, :integer, :null => false
|
10
11
|
t.column :read, :boolean, :default => false
|
11
12
|
t.column :trashed, :boolean, :default => false
|
13
|
+
t.column :deleted, :boolean, :default => false
|
12
14
|
t.column :mailbox_type, :string, :limit => 25
|
13
15
|
t.column :created_at, :datetime, :null => false
|
16
|
+
t.column :updated_at, :datetime, :null => false
|
14
17
|
end
|
15
18
|
create_table :mailboxer_messages do |t|
|
16
19
|
t.column :body, :text
|
@@ -19,6 +22,9 @@ class CreateMailboxer < ActiveRecord::Migration
|
|
19
22
|
t.references :sender, :polymorphic => true
|
20
23
|
t.column :mailboxer_conversation_id, :integer
|
21
24
|
t.column :sent, :boolean, :default => false
|
25
|
+
t.column :draft, :boolean, :default => false
|
26
|
+
t.column :system, :boolean, :default => false
|
27
|
+
t.column :updated_at, :datetime, :null => false
|
22
28
|
t.column :created_at, :datetime, :null => false
|
23
29
|
end
|
24
30
|
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -10,38 +10,18 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended to check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(:version =>
|
13
|
+
ActiveRecord::Schema.define(:version => 20110306015107) do
|
14
14
|
|
15
|
-
create_table "
|
15
|
+
create_table "cylons", :force => true do |t|
|
16
16
|
t.string "name"
|
17
17
|
t.datetime "created_at"
|
18
18
|
t.datetime "updated_at"
|
19
19
|
end
|
20
20
|
|
21
|
-
create_table "
|
22
|
-
t.string "
|
23
|
-
t.datetime "created_at"
|
24
|
-
|
25
|
-
|
26
|
-
create_table "mailboxer_mails", :force => true do |t|
|
27
|
-
t.integer "receiver_id"
|
28
|
-
t.string "receiver_type"
|
29
|
-
t.integer "mailboxer_message_id", :null => false
|
30
|
-
t.boolean "read", :default => false
|
31
|
-
t.boolean "trashed", :default => false
|
32
|
-
t.string "mailbox_type", :limit => 25
|
33
|
-
t.datetime "created_at", :null => false
|
34
|
-
end
|
35
|
-
|
36
|
-
create_table "mailboxer_messages", :force => true do |t|
|
37
|
-
t.text "body"
|
38
|
-
t.string "subject", :default => ""
|
39
|
-
t.text "headers"
|
40
|
-
t.integer "sender_id"
|
41
|
-
t.string "sender_type"
|
42
|
-
t.integer "mailboxer_conversation_id"
|
43
|
-
t.boolean "sent", :default => false
|
44
|
-
t.datetime "created_at", :null => false
|
21
|
+
create_table "ducks", :force => true do |t|
|
22
|
+
t.string "name"
|
23
|
+
t.datetime "created_at"
|
24
|
+
t.datetime "updated_at"
|
45
25
|
end
|
46
26
|
|
47
27
|
create_table "users", :force => true do |t|
|
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:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eduardo Casanova Cuesta
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-22 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -229,9 +229,9 @@ files:
|
|
229
229
|
- spec/dummy/config/locales/en.yml
|
230
230
|
- spec/dummy/config/routes.rb
|
231
231
|
- spec/dummy/db/migrate/20110228120600_create_users.rb
|
232
|
-
- spec/dummy/db/migrate/20110303122122_create_mailboxer.rb
|
233
232
|
- spec/dummy/db/migrate/20110306002940_create_ducks.rb
|
234
233
|
- spec/dummy/db/migrate/20110306015107_create_cylons.rb
|
234
|
+
- spec/dummy/db/migrate/20110321231559_create_mailboxer.rb
|
235
235
|
- spec/dummy/db/schema.rb
|
236
236
|
- spec/dummy/public/404.html
|
237
237
|
- spec/dummy/public/422.html
|