feat: Customisable Email Templates (#1095)
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
DROPPABLES = %w[Account Channel Conversation Inbox User].freeze
|
||||
|
||||
def to_drop
|
||||
return unless DROPPABLES.include?(self.class.name)
|
||||
|
||||
"#{self.class.name}Drop".constantize.new(self)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,8 +52,10 @@ class Conversation < ApplicationRecord
|
||||
|
||||
before_create :set_display_id, unless: :display_id?
|
||||
before_create :set_bot_conversation
|
||||
after_create :notify_conversation_creation
|
||||
after_create_commit :notify_conversation_creation
|
||||
after_save :run_round_robin
|
||||
# wanted to change this to after_update commit. But it ended up creating a loop
|
||||
# reinvestigate in future and identity the implications
|
||||
after_update :notify_status_change, :create_activity
|
||||
|
||||
acts_as_taggable_on :labels
|
||||
|
||||
28
app/models/email_template.rb
Normal file
28
app/models/email_template.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: email_templates
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# body :text not null
|
||||
# locale :integer default("en"), not null
|
||||
# name :string not null
|
||||
# template_type :integer default("content")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :integer
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_email_templates_on_name_and_account_id (name,account_id) UNIQUE
|
||||
#
|
||||
class EmailTemplate < ApplicationRecord
|
||||
enum locale: LANGUAGES_CONFIG.map { |key, val| [val[:iso_639_1_code], key] }.to_h
|
||||
enum template_type: { layout: 0, content: 1 }
|
||||
belongs_to :account, optional: true
|
||||
|
||||
validates :name, uniqueness: { scope: :account }
|
||||
|
||||
def self.resolver(options = {})
|
||||
::EmailTemplates::DbResolverService.using self, options
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user