2016-01-18 18:57:55 -05:00
|
|
|
class IncomingEmail < ActiveRecord::Base
|
|
|
|
belongs_to :user
|
|
|
|
belongs_to :topic
|
|
|
|
belongs_to :post
|
|
|
|
|
2017-08-04 10:20:44 -04:00
|
|
|
scope :errored, -> { where("NOT is_bounce AND error IS NOT NULL") }
|
2017-11-13 09:20:36 -05:00
|
|
|
|
|
|
|
scope :addressed_to, -> (email) { where('incoming_emails.to_addresses ILIKE :email OR incoming_emails.cc_addresses ILIKE :email', email: "%#{email}%") }
|
2016-01-18 18:57:55 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: incoming_emails
|
|
|
|
#
|
2016-03-28 00:21:45 -04:00
|
|
|
# id :integer not null, primary key
|
|
|
|
# user_id :integer
|
|
|
|
# topic_id :integer
|
|
|
|
# post_id :integer
|
|
|
|
# raw :text
|
|
|
|
# error :text
|
|
|
|
# message_id :text
|
|
|
|
# from_address :text
|
|
|
|
# to_addresses :text
|
|
|
|
# cc_addresses :text
|
|
|
|
# subject :text
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
# rejection_message :text
|
2016-05-29 20:45:32 -04:00
|
|
|
# is_auto_generated :boolean default(FALSE)
|
|
|
|
# is_bounce :boolean default(FALSE), not null
|
2016-01-18 18:57:55 -05:00
|
|
|
#
|
|
|
|
# Indexes
|
|
|
|
#
|
|
|
|
# index_incoming_emails_on_created_at (created_at)
|
|
|
|
# index_incoming_emails_on_error (error)
|
|
|
|
# index_incoming_emails_on_message_id (message_id)
|
2016-05-29 20:45:32 -04:00
|
|
|
# index_incoming_emails_on_post_id (post_id)
|
2016-01-18 18:57:55 -05:00
|
|
|
#
|