Merge branch 'develop' into send-on-email-service
This commit is contained in:
@@ -40,6 +40,12 @@ class Channel::Email < ApplicationRecord
|
||||
|
||||
AUTHORIZATION_ERROR_THRESHOLD = 10
|
||||
|
||||
# TODO: Remove guard once encryption keys become mandatory (target 3-4 releases out).
|
||||
if Chatwoot.encryption_configured?
|
||||
encrypts :imap_password
|
||||
encrypts :smtp_password
|
||||
end
|
||||
|
||||
self.table_name = 'channel_email'
|
||||
EDITABLE_ATTRS = [:email, :imap_enabled, :imap_login, :imap_password, :imap_address, :imap_port, :imap_enable_ssl,
|
||||
:smtp_enabled, :smtp_login, :smtp_password, :smtp_address, :smtp_port, :smtp_domain, :smtp_enable_starttls_auto,
|
||||
|
||||
@@ -21,6 +21,12 @@ class Channel::FacebookPage < ApplicationRecord
|
||||
include Channelable
|
||||
include Reauthorizable
|
||||
|
||||
# TODO: Remove guard once encryption keys become mandatory (target 3-4 releases out).
|
||||
if Chatwoot.encryption_configured?
|
||||
encrypts :page_access_token
|
||||
encrypts :user_access_token
|
||||
end
|
||||
|
||||
self.table_name = 'channel_facebook_pages'
|
||||
|
||||
validates :page_id, uniqueness: { scope: :account_id }
|
||||
|
||||
@@ -19,6 +19,9 @@ class Channel::Instagram < ApplicationRecord
|
||||
include Reauthorizable
|
||||
self.table_name = 'channel_instagram'
|
||||
|
||||
# TODO: Remove guard once encryption keys become mandatory (target 3-4 releases out).
|
||||
encrypts :access_token if Chatwoot.encryption_configured?
|
||||
|
||||
AUTHORIZATION_ERROR_THRESHOLD = 1
|
||||
|
||||
validates :access_token, presence: true
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
class Channel::Line < ApplicationRecord
|
||||
include Channelable
|
||||
|
||||
# TODO: Remove guard once encryption keys become mandatory (target 3-4 releases out).
|
||||
if Chatwoot.encryption_configured?
|
||||
encrypts :line_channel_secret
|
||||
encrypts :line_channel_token
|
||||
end
|
||||
|
||||
self.table_name = 'channel_line'
|
||||
EDITABLE_ATTRS = [:line_channel_id, :line_channel_secret, :line_channel_token].freeze
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
class Channel::Telegram < ApplicationRecord
|
||||
include Channelable
|
||||
|
||||
# TODO: Remove guard once encryption keys become mandatory (target 3-4 releases out).
|
||||
encrypts :bot_token, deterministic: true if Chatwoot.encryption_configured?
|
||||
|
||||
self.table_name = 'channel_telegram'
|
||||
EDITABLE_ATTRS = [:bot_token].freeze
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@ class Channel::TwilioSms < ApplicationRecord
|
||||
|
||||
self.table_name = 'channel_twilio_sms'
|
||||
|
||||
# TODO: Remove guard once encryption keys become mandatory (target 3-4 releases out).
|
||||
encrypts :auth_token if Chatwoot.encryption_configured?
|
||||
|
||||
validates :account_sid, presence: true
|
||||
# The same parameter is used to store api_key_secret if api_key authentication is opted
|
||||
validates :auth_token, presence: true
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
class Channel::TwitterProfile < ApplicationRecord
|
||||
include Channelable
|
||||
|
||||
# TODO: Remove guard once encryption keys become mandatory (target 3-4 releases out).
|
||||
if Chatwoot.encryption_configured?
|
||||
encrypts :twitter_access_token
|
||||
encrypts :twitter_access_token_secret
|
||||
end
|
||||
|
||||
self.table_name = 'channel_twitter_profiles'
|
||||
|
||||
validates :profile_id, uniqueness: { scope: :account_id }
|
||||
|
||||
@@ -106,7 +106,7 @@ module ActivityMessageHandler
|
||||
end
|
||||
|
||||
def generate_assignee_change_activity_content(user_name)
|
||||
params = { assignee_name: assignee&.name, user_name: user_name }.compact
|
||||
params = { assignee_name: assignee&.name || '', user_name: user_name }
|
||||
key = assignee_id ? 'assigned' : 'removed'
|
||||
key = 'self_assigned' if self_assign? assignee_id
|
||||
I18n.t("conversations.activity.assignee.#{key}", **params)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :integer not null
|
||||
# company_id :bigint
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
@@ -28,6 +29,7 @@
|
||||
# index_contacts_on_account_id_and_contact_type (account_id,contact_type)
|
||||
# index_contacts_on_account_id_and_last_activity_at (account_id,last_activity_at DESC NULLS LAST)
|
||||
# index_contacts_on_blocked (blocked)
|
||||
# index_contacts_on_company_id (company_id)
|
||||
# index_contacts_on_lower_email_account_id (lower((email)::text), account_id)
|
||||
# index_contacts_on_name_email_phone_number_identifier (name,email,phone_number,identifier) USING gin
|
||||
# index_contacts_on_nonempty_fields (account_id,email,phone_number,identifier) WHERE (((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text))
|
||||
@@ -244,3 +246,4 @@ class Contact < ApplicationRecord
|
||||
Rails.configuration.dispatcher.dispatch(CONTACT_DELETED, Time.zone.now, contact: self)
|
||||
end
|
||||
end
|
||||
Contact.include_mod_with('Concerns::Contact')
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
# index_custom_filters_on_user_id (user_id)
|
||||
#
|
||||
class CustomFilter < ApplicationRecord
|
||||
MAX_FILTER_PER_USER = 50
|
||||
belongs_to :user
|
||||
belongs_to :account
|
||||
|
||||
@@ -25,7 +24,7 @@ class CustomFilter < ApplicationRecord
|
||||
validate :validate_number_of_filters
|
||||
|
||||
def validate_number_of_filters
|
||||
return true if account.custom_filters.where(user_id: user_id).size < MAX_FILTER_PER_USER
|
||||
return true if account.custom_filters.where(user_id: user_id).size < Limits::MAX_CUSTOM_FILTERS_PER_USER
|
||||
|
||||
errors.add :account_id, I18n.t('errors.custom_filters.number_of_records')
|
||||
end
|
||||
|
||||
@@ -21,6 +21,9 @@ class Integrations::Hook < ApplicationRecord
|
||||
before_validation :ensure_hook_type
|
||||
after_create :trigger_setup_if_crm
|
||||
|
||||
# TODO: Remove guard once encryption keys become mandatory (target 3-4 releases out).
|
||||
encrypts :access_token, deterministic: true if Chatwoot.encryption_configured?
|
||||
|
||||
validates :account_id, presence: true
|
||||
validates :app_id, presence: true
|
||||
validates :inbox_id, presence: true, if: -> { hook_type == 'inbox' }
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#
|
||||
|
||||
class Message < ApplicationRecord
|
||||
searchkick callbacks: :async if ChatwootApp.advanced_search_allowed?
|
||||
searchkick callbacks: false if ChatwootApp.advanced_search_allowed?
|
||||
|
||||
include MessageFilterHelpers
|
||||
include Liquidable
|
||||
@@ -135,6 +135,7 @@ class Message < ApplicationRecord
|
||||
after_create_commit :execute_after_create_commit_callbacks
|
||||
|
||||
after_update_commit :dispatch_update_event
|
||||
after_commit :reindex_for_search, if: :should_index?, on: [:create, :update]
|
||||
|
||||
def channel_token
|
||||
@token ||= inbox.channel.try(:page_access_token)
|
||||
@@ -393,6 +394,10 @@ class Message < ApplicationRecord
|
||||
conversation.update_columns(last_activity_at: created_at)
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
end
|
||||
|
||||
def reindex_for_search
|
||||
reindex(mode: :async)
|
||||
end
|
||||
end
|
||||
|
||||
Message.prepend_mod_with('Message')
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
# message_signature :text
|
||||
# name :string not null
|
||||
# otp_backup_codes :text
|
||||
# otp_required_for_login :boolean default(FALSE), not null
|
||||
# otp_required_for_login :boolean default(FALSE)
|
||||
# otp_secret :string
|
||||
# provider :string default("email"), not null
|
||||
# pubsub_token :string
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
# message_signature :text
|
||||
# name :string not null
|
||||
# otp_backup_codes :text
|
||||
# otp_required_for_login :boolean default(FALSE), not null
|
||||
# otp_required_for_login :boolean default(FALSE)
|
||||
# otp_secret :string
|
||||
# provider :string default("email"), not null
|
||||
# pubsub_token :string
|
||||
|
||||
Reference in New Issue
Block a user