mirror of
https://github.com/docusealco/docuseal
synced 2026-11-05 06:42:32 -05:00
add email events
This commit is contained in:
1 parent
db302858c4
commit
cdda55d528
9 files changed
+151
-1
No files matched your search
@@ -31,6 +31,7 @@ class Account < ApplicationRecord
|
||||
has_many :submissions, dependent: :destroy
|
||||
has_many :submitters, through: :submissions
|
||||
has_many :account_linked_accounts, dependent: :destroy
|
||||
has_many :email_events, dependent: :destroy
|
||||
has_many :account_testing_accounts, -> { testing }, dependent: :destroy,
|
||||
class_name: 'AccountLinkedAccount',
|
||||
inverse_of: :account
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: email_events
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# data :text not null
|
||||
# email :string not null
|
||||
# emailable_type :string not null
|
||||
# event_datetime :datetime not null
|
||||
# event_type :string not null
|
||||
# tag :string not null
|
||||
# created_at :datetime not null
|
||||
# account_id :bigint not null
|
||||
# emailable_id :bigint not null
|
||||
# message_id :string not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_email_events_on_account_id (account_id)
|
||||
# index_email_events_on_emailable (emailable_type,emailable_id)
|
||||
# index_email_events_on_message_id (message_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (account_id => accounts.id)
|
||||
#
|
||||
class EmailEvent < ApplicationRecord
|
||||
belongs_to :emailable, polymorphic: true
|
||||
belongs_to :account
|
||||
|
||||
attribute :data, :string, default: -> { {} }
|
||||
|
||||
serialize :data, coder: JSON
|
||||
|
||||
before_validation :maybe_set_account, on: :create
|
||||
|
||||
def maybe_set_account
|
||||
self.account ||= emailable.account
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user