@@ -59,7 +59,7 @@ class ConfigLoader
|
||||
end
|
||||
|
||||
def save_as_new_config(latest)
|
||||
config = InstallationConfig.find_or_create_by(name: latest[:name])
|
||||
config = InstallationConfig.find_or_initialize_by(name: latest[:name])
|
||||
config.value = latest[:value]
|
||||
config.locked = latest[:locked]
|
||||
config.save!
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
require 'google/cloud/dialogflow/v2'
|
||||
|
||||
class Integrations::Dialogflow::ProcessorService < Integrations::BotProcessorService
|
||||
pattr_initialize [:event_name!, :hook!, :event_data!]
|
||||
|
||||
@@ -17,11 +19,15 @@ class Integrations::Dialogflow::ProcessorService < Integrations::BotProcessorSer
|
||||
Rails.logger.warn "Account: #{hook.try(:account_id)} Hook: #{hook.id} credentials are not present." && return
|
||||
end
|
||||
|
||||
Google::Cloud::Dialogflow.configure { |config| config.credentials = hook.settings['credentials'] }
|
||||
session_client = Google::Cloud::Dialogflow.sessions
|
||||
session = session_client.session_path project: hook.settings['project_id'], session: session_id
|
||||
::Google::Cloud::Dialogflow::V2::Sessions::Client.configure do |config|
|
||||
config.timeout = 10.0
|
||||
config.credentials = hook.settings['credentials']
|
||||
end
|
||||
|
||||
client = ::Google::Cloud::Dialogflow::V2::Sessions::Client.new
|
||||
session = "projects/#{hook.settings['project_id']}/agent/sessions/#{session_id}"
|
||||
query_input = { text: { text: message, language_code: 'en-US' } }
|
||||
session_client.detect_intent session: session, query_input: query_input
|
||||
client.detect_intent session: session, query_input: query_input
|
||||
end
|
||||
|
||||
def process_response(message, response)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
require 'google/cloud/translate/v3'
|
||||
class Integrations::GoogleTranslate::DetectLanguageService
|
||||
pattr_initialize [:hook!, :message!]
|
||||
|
||||
@@ -33,7 +34,7 @@ class Integrations::GoogleTranslate::DetectLanguageService
|
||||
end
|
||||
|
||||
def client
|
||||
@client ||= Google::Cloud::Translate.translation_service do |config|
|
||||
@client ||= ::Google::Cloud::Translate::V3::TranslationService::Client.new do |config|
|
||||
config.credentials = hook.settings['credentials']
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
require 'google/cloud/translate/v3'
|
||||
class Integrations::GoogleTranslate::ProcessorService
|
||||
pattr_initialize [:message!, :target_language!]
|
||||
|
||||
@@ -23,7 +24,7 @@ class Integrations::GoogleTranslate::ProcessorService
|
||||
end
|
||||
|
||||
def client
|
||||
@client ||= Google::Cloud::Translate.translation_service do |config|
|
||||
@client ||= ::Google::Cloud::Translate::V3::TranslationService::Client.new do |config|
|
||||
config.credentials = hook.settings['credentials']
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ module Redis::Config
|
||||
password: ENV.fetch('REDIS_PASSWORD', nil).presence,
|
||||
ssl_params: { verify_mode: Chatwoot.redis_ssl_verify_mode },
|
||||
reconnect_attempts: 2,
|
||||
network_timeout: 5
|
||||
timeout: 1
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@ db_namespace = namespace :db do
|
||||
desc 'Runs setup if database does not exist, or runs migrations if it does'
|
||||
task chatwoot_prepare: :load_config do
|
||||
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env).each do |db_config|
|
||||
ActiveRecord::Base.establish_connection(db_config.config)
|
||||
# handling case where database was created by the provider, with out running db:setup
|
||||
ActiveRecord::Base.establish_connection(db_config.configuration_hash)
|
||||
unless ActiveRecord::Base.connection.table_exists? 'ar_internal_metadata'
|
||||
db_namespace['load_config'].invoke if ActiveRecord::Base.schema_format == :ruby
|
||||
ActiveRecord::Tasks::DatabaseTasks.load_schema_current(:ruby, ENV.fetch('SCHEMA', nil))
|
||||
|
||||
10
lib/tasks/yarn.rake
Normal file
10
lib/tasks/yarn.rake
Normal file
@@ -0,0 +1,10 @@
|
||||
# ref: https://github.com/rails/rails/issues/43906#issuecomment-1094380699
|
||||
# https://github.com/rails/rails/issues/43906#issuecomment-1099992310
|
||||
task before_assets_precompile: :environment do
|
||||
# run a command which starts your packaging
|
||||
system('yarn')
|
||||
end
|
||||
|
||||
# every time you execute 'rake assets:precompile'
|
||||
# run 'before_assets_precompile' first
|
||||
Rake::Task['assets:precompile'].enhance ['before_assets_precompile']
|
||||
Reference in New Issue
Block a user