install mailboxer gem to db + user model

This commit is contained in:
Devin Howard 2016-11-01 11:18:27 +08:00
parent 1ba339b3be
commit 3c1d163984
9 changed files with 198 additions and 0 deletions

View file

@ -17,6 +17,7 @@ gem 'exception_notification'
gem 'httparty'
gem 'json'
gem 'kaminari'
gem 'mailboxer'
gem 'paperclip'
gem 'pg'
gem 'pundit'

View file

@ -65,6 +65,12 @@ GEM
brakeman (3.4.0)
builder (3.2.2)
byebug (9.0.5)
carrierwave (0.11.2)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
mimemagic (>= 0.3.0)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.8)
@ -125,6 +131,9 @@ GEM
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
mailboxer (0.14.0)
carrierwave (>= 0.5.8)
rails (>= 4.2.0)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
@ -284,6 +293,7 @@ DEPENDENCIES
json
json-schema
kaminari
mailboxer
paperclip
pg
pry-byebug

View file

@ -2,6 +2,8 @@
require 'open-uri'
class User < ApplicationRecord
acts_as_messageable # mailboxer notifications
has_many :topics
has_many :synapses
has_many :maps

View file

@ -0,0 +1,21 @@
Mailboxer.setup do |config|
#Configures if your application uses or not email sending for Notifications and Messages
config.uses_emails = true
#Configures the default from for emails sent for Messages and Notifications
config.default_from = "no-reply@metamaps.cc"
#Configures the methods needed by mailboxer
config.email_method = :mailboxer_email
config.name_method = :name
#Configures if you use or not a search engine and which one you are using
#Supported engines: [:solr,:sphinx]
config.search_enabled = false
config.search_engine = :solr
#Configures maximum length of the message subject and body
config.subject_max_length = 255
config.body_max_length = 32000
end

View file

@ -0,0 +1,65 @@
# This migration comes from mailboxer_engine (originally 20110511145103)
class CreateMailboxer < ActiveRecord::Migration
def self.up
#Tables
#Conversations
create_table :mailboxer_conversations do |t|
t.column :subject, :string, :default => ""
t.column :created_at, :datetime, :null => false
t.column :updated_at, :datetime, :null => false
end
#Receipts
create_table :mailboxer_receipts do |t|
t.references :receiver, :polymorphic => true
t.column :notification_id, :integer, :null => false
t.column :is_read, :boolean, :default => false
t.column :trashed, :boolean, :default => false
t.column :deleted, :boolean, :default => false
t.column :mailbox_type, :string, :limit => 25
t.column :created_at, :datetime, :null => false
t.column :updated_at, :datetime, :null => false
end
#Notifications and Messages
create_table :mailboxer_notifications do |t|
t.column :type, :string
t.column :body, :text
t.column :subject, :string, :default => ""
t.references :sender, :polymorphic => true
t.column :conversation_id, :integer
t.column :draft, :boolean, :default => false
t.string :notification_code, :default => nil
t.references :notified_object, :polymorphic => true
t.column :attachment, :string
t.column :updated_at, :datetime, :null => false
t.column :created_at, :datetime, :null => false
t.boolean :global, default: false
t.datetime :expires
end
#Indexes
#Conversations
#Receipts
add_index "mailboxer_receipts","notification_id"
#Messages
add_index "mailboxer_notifications","conversation_id"
#Foreign keys
#Conversations
#Receipts
add_foreign_key "mailboxer_receipts", "mailboxer_notifications", :name => "receipts_on_notification_id", :column => "notification_id"
#Messages
add_foreign_key "mailboxer_notifications", "mailboxer_conversations", :name => "notifications_on_conversation_id", :column => "conversation_id"
end
def self.down
#Tables
remove_foreign_key "mailboxer_receipts", :name => "receipts_on_notification_id"
remove_foreign_key "mailboxer_notifications", :name => "notifications_on_conversation_id"
#Indexes
drop_table :mailboxer_receipts
drop_table :mailboxer_conversations
drop_table :mailboxer_notifications
end
end

View file

@ -0,0 +1,15 @@
# This migration comes from mailboxer_engine (originally 20131206080416)
class AddConversationOptout < ActiveRecord::Migration
def self.up
create_table :mailboxer_conversation_opt_outs do |t|
t.references :unsubscriber, :polymorphic => true
t.references :conversation
end
add_foreign_key "mailboxer_conversation_opt_outs", "mailboxer_conversations", :name => "mb_opt_outs_on_conversations_id", :column => "conversation_id"
end
def self.down
remove_foreign_key "mailboxer_conversation_opt_outs", :name => "mb_opt_outs_on_conversations_id"
drop_table :mailboxer_conversation_opt_outs
end
end

View file

@ -0,0 +1,20 @@
# This migration comes from mailboxer_engine (originally 20131206080417)
class AddMissingIndices < ActiveRecord::Migration
def change
# We'll explicitly specify its name, as the auto-generated name is too long and exceeds 63
# characters limitation.
add_index :mailboxer_conversation_opt_outs, [:unsubscriber_id, :unsubscriber_type],
name: 'index_mailboxer_conversation_opt_outs_on_unsubscriber_id_type'
add_index :mailboxer_conversation_opt_outs, :conversation_id
add_index :mailboxer_notifications, :type
add_index :mailboxer_notifications, [:sender_id, :sender_type]
# We'll explicitly specify its name, as the auto-generated name is too long and exceeds 63
# characters limitation.
add_index :mailboxer_notifications, [:notified_object_id, :notified_object_type],
name: 'index_mailboxer_notifications_on_notified_object_id_and_type'
add_index :mailboxer_receipts, [:receiver_id, :receiver_type]
end
end

View file

@ -0,0 +1,8 @@
# This migration comes from mailboxer_engine (originally 20151103080417)
class AddDeliveryTrackingInfoToMailboxerReceipts < ActiveRecord::Migration
def change
add_column :mailboxer_receipts, :is_delivered, :boolean, default: false
add_column :mailboxer_receipts, :delivery_method, :string
add_column :mailboxer_receipts, :message_id, :string
end
end

View file

@ -63,6 +63,59 @@ ActiveRecord::Schema.define(version: 20161105160340) do
t.index ["metacode_set_id"], name: "index_in_metacode_sets_on_metacode_set_id", using: :btree
end
create_table "mailboxer_conversation_opt_outs", force: :cascade do |t|
t.string "unsubscriber_type"
t.integer "unsubscriber_id"
t.integer "conversation_id"
t.index ["conversation_id"], name: "index_mailboxer_conversation_opt_outs_on_conversation_id", using: :btree
t.index ["unsubscriber_id", "unsubscriber_type"], name: "index_mailboxer_conversation_opt_outs_on_unsubscriber_id_type", using: :btree
end
create_table "mailboxer_conversations", force: :cascade do |t|
t.string "subject", default: ""
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "mailboxer_notifications", force: :cascade do |t|
t.string "type"
t.text "body"
t.string "subject", default: ""
t.string "sender_type"
t.integer "sender_id"
t.integer "conversation_id"
t.boolean "draft", default: false
t.string "notification_code"
t.string "notified_object_type"
t.integer "notified_object_id"
t.string "attachment"
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.boolean "global", default: false
t.datetime "expires"
t.index ["conversation_id"], name: "index_mailboxer_notifications_on_conversation_id", using: :btree
t.index ["notified_object_id", "notified_object_type"], name: "index_mailboxer_notifications_on_notified_object_id_and_type", using: :btree
t.index ["sender_id", "sender_type"], name: "index_mailboxer_notifications_on_sender_id_and_sender_type", using: :btree
t.index ["type"], name: "index_mailboxer_notifications_on_type", using: :btree
end
create_table "mailboxer_receipts", force: :cascade do |t|
t.string "receiver_type"
t.integer "receiver_id"
t.integer "notification_id", null: false
t.boolean "is_read", default: false
t.boolean "trashed", default: false
t.boolean "deleted", default: false
t.string "mailbox_type", limit: 25
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "is_delivered", default: false
t.string "delivery_method"
t.string "message_id"
t.index ["notification_id"], name: "index_mailboxer_receipts_on_notification_id", using: :btree
t.index ["receiver_id", "receiver_type"], name: "index_mailboxer_receipts_on_receiver_id_and_receiver_type", using: :btree
end
create_table "mappings", force: :cascade do |t|
t.text "category"
t.integer "xloc"
@ -279,5 +332,8 @@ ActiveRecord::Schema.define(version: 20161105160340) do
add_foreign_key "access_requests", "maps"
add_foreign_key "access_requests", "users"
add_foreign_key "mailboxer_conversation_opt_outs", "mailboxer_conversations", column: "conversation_id", name: "mb_opt_outs_on_conversations_id"
add_foreign_key "mailboxer_notifications", "mailboxer_conversations", column: "conversation_id", name: "notifications_on_conversation_id"
add_foreign_key "mailboxer_receipts", "mailboxer_notifications", column: "notification_id", name: "receipts_on_notification_id"
add_foreign_key "tokens", "users"
end