2020-12-27 11:45:20 +01:00
|
|
|
class Email
|
|
|
|
include ActiveModel::Model
|
|
|
|
include ActiveModel::Attributes
|
2020-12-28 13:02:56 +01:00
|
|
|
include ActiveModel::Conversion
|
2020-12-27 11:45:20 +01:00
|
|
|
|
2020-12-28 13:02:56 +01:00
|
|
|
attribute :id
|
2020-12-27 11:45:20 +01:00
|
|
|
attribute :message_id
|
|
|
|
attribute :subject
|
|
|
|
attribute :date, :datetime
|
|
|
|
attribute :to
|
|
|
|
attribute :delivered_to
|
|
|
|
attribute :from
|
|
|
|
attribute :headers, default: []
|
|
|
|
attribute :plain_body
|
2020-12-31 15:32:07 +01:00
|
|
|
attribute :cron, :boolean, default: false
|
|
|
|
attribute :mailing_list, :boolean, default: false
|
2020-12-27 11:45:20 +01:00
|
|
|
attribute :clients, default: []
|
|
|
|
attribute :servers, default: []
|
|
|
|
attribute :tickets, default: []
|
|
|
|
attribute :created_at, :datetime, default: DateTime.now
|
|
|
|
attribute :updated_at, :datetime, default: DateTime.now
|
|
|
|
|
2020-12-31 15:32:07 +01:00
|
|
|
validates :message_id, presence: true
|
|
|
|
validates :subject, presence: true
|
|
|
|
validates :date, presence: true
|
|
|
|
validates :delivered_to, presence: true
|
|
|
|
validates :from, presence: true
|
|
|
|
validates :headers, presence: true
|
2020-12-28 00:51:22 +01:00
|
|
|
|
|
|
|
def to_hash
|
|
|
|
attributes
|
|
|
|
end
|
2020-12-28 13:02:56 +01:00
|
|
|
|
|
|
|
def persisted?
|
|
|
|
id.present?
|
|
|
|
end
|
2020-12-31 15:31:48 +01:00
|
|
|
|
|
|
|
def cron?
|
|
|
|
cron
|
|
|
|
end
|
|
|
|
|
|
|
|
def mailing_list?
|
|
|
|
mailing_list
|
|
|
|
end
|
2020-10-28 23:53:42 +01:00
|
|
|
end
|