chore: Update dependencies to the latest versions (#5033)
This commit is contained in:
@@ -9,12 +9,15 @@ class Campaigns::CampaignConversationBuilder
|
||||
@contact_inbox.lock!
|
||||
|
||||
# We won't send campaigns if a conversation is already present
|
||||
return if @contact_inbox.reload.conversations.present?
|
||||
raise 'Conversation alread present' if @contact_inbox.reload.conversations.present?
|
||||
|
||||
@conversation = ::Conversation.create!(conversation_params)
|
||||
Messages::MessageBuilder.new(@campaign.sender, @conversation, message_params).perform
|
||||
end
|
||||
@conversation
|
||||
rescue StandardError => e
|
||||
Rails.logger.info(e.message)
|
||||
nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -14,7 +14,7 @@ class Platform::Api::V1::UsersController < PlatformController
|
||||
|
||||
def login
|
||||
encoded_email = ERB::Util.url_encode(@resource.email)
|
||||
render json: { url: "#{ENV['FRONTEND_URL']}/app/login?email=#{encoded_email}&sso_auth_token=#{@resource.generate_sso_auth_token}" }
|
||||
render json: { url: "#{ENV.fetch('FRONTEND_URL', nil)}/app/login?email=#{encoded_email}&sso_auth_token=#{@resource.generate_sso_auth_token}" }
|
||||
end
|
||||
|
||||
def show; end
|
||||
|
||||
@@ -47,7 +47,7 @@ class ContactIpLookupJob < ApplicationJob
|
||||
def setup_vendor_db
|
||||
base_url = 'https://download.maxmind.com/app/geoip_download'
|
||||
source_file = Down.download(
|
||||
"#{base_url}?edition_id=GeoLite2-City&suffix=tar.gz&license_key=#{ENV['IP_LOOKUP_API_KEY']}"
|
||||
"#{base_url}?edition_id=GeoLite2-City&suffix=tar.gz&license_key=#{ENV.fetch('IP_LOOKUP_API_KEY', nil)}"
|
||||
)
|
||||
tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(source_file))
|
||||
tar_extract.rewind
|
||||
|
||||
@@ -3,7 +3,7 @@ class AdministratorNotifications::ChannelNotificationsMailer < ApplicationMailer
|
||||
return unless smtp_config_set_or_development?
|
||||
|
||||
subject = 'Your Slack integration has expired'
|
||||
@action_url = "#{ENV['FRONTEND_URL']}/app/accounts/#{Current.account.id}/settings/integrations/slack"
|
||||
@action_url = "#{ENV.fetch('FRONTEND_URL', nil)}/app/accounts/#{Current.account.id}/settings/integrations/slack"
|
||||
send_mail_with_liquid(to: admin_emails, subject: subject) and return
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ class AdministratorNotifications::ChannelNotificationsMailer < ApplicationMailer
|
||||
return unless smtp_config_set_or_development?
|
||||
|
||||
subject = 'Your Facebook page connection has expired'
|
||||
@action_url = "#{ENV['FRONTEND_URL']}/app/accounts/#{Current.account.id}/settings/inboxes/#{inbox.id}"
|
||||
@action_url = "#{ENV.fetch('FRONTEND_URL', nil)}/app/accounts/#{Current.account.id}/settings/inboxes/#{inbox.id}"
|
||||
send_mail_with_liquid(to: admin_emails, subject: subject) and return
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ class AdministratorNotifications::ChannelNotificationsMailer < ApplicationMailer
|
||||
return unless smtp_config_set_or_development?
|
||||
|
||||
subject = 'Your email inbox has been disconnected. Please update the credentials for SMTP/IMAP'
|
||||
@action_url = "#{ENV['FRONTEND_URL']}/app/accounts/#{Current.account.id}/settings/inboxes/#{inbox.id}"
|
||||
@action_url = "#{ENV.fetch('FRONTEND_URL', nil)}/app/accounts/#{Current.account.id}/settings/inboxes/#{inbox.id}"
|
||||
send_mail_with_liquid(to: admin_emails, subject: subject) and return
|
||||
end
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ class Account < ApplicationRecord
|
||||
end
|
||||
|
||||
def support_email
|
||||
super || ENV['MAILER_SENDER_EMAIL'] || GlobalConfig.get('MAILER_SUPPORT_EMAIL')['MAILER_SUPPORT_EMAIL']
|
||||
super || ENV.fetch('MAILER_SENDER_EMAIL') { GlobalConfig.get('MAILER_SUPPORT_EMAIL')['MAILER_SUPPORT_EMAIL'] }
|
||||
end
|
||||
|
||||
def usage_limits
|
||||
|
||||
@@ -63,7 +63,7 @@ class Category < ApplicationRecord
|
||||
validates :name, presence: true
|
||||
validate :allowed_locales
|
||||
validates :locale, uniqueness: { scope: %i[slug portal_id],
|
||||
message: 'should be unique in the category and portal' }
|
||||
message: I18n.t('errors.categories.locale.unique') }
|
||||
accepts_nested_attributes_for :related_categories
|
||||
|
||||
scope :search_by_locale, ->(locale) { where(locale: locale) if locale.present? }
|
||||
|
||||
@@ -72,7 +72,7 @@ class Channel::Telegram < ApplicationRecord
|
||||
HTTParty.post("#{telegram_api_url}/deleteWebhook")
|
||||
response = HTTParty.post("#{telegram_api_url}/setWebhook",
|
||||
body: {
|
||||
url: "#{ENV['FRONTEND_URL']}/webhooks/telegram/#{bot_token}"
|
||||
url: "#{ENV.fetch('FRONTEND_URL', nil)}/webhooks/telegram/#{bot_token}"
|
||||
})
|
||||
errors.add(:bot_token, 'error setting up the webook') unless response.success?
|
||||
end
|
||||
|
||||
@@ -29,11 +29,11 @@ class Contact < ApplicationRecord
|
||||
|
||||
validates :account_id, presence: true
|
||||
validates :email, allow_blank: true, uniqueness: { scope: [:account_id], case_sensitive: false },
|
||||
format: { with: Devise.email_regexp, message: 'Invalid email' }
|
||||
format: { with: Devise.email_regexp, message: I18n.t('errors.contacts.email.invalid') }
|
||||
validates :identifier, allow_blank: true, uniqueness: { scope: [:account_id] }
|
||||
validates :phone_number,
|
||||
allow_blank: true, uniqueness: { scope: [:account_id] },
|
||||
format: { with: /\+[1-9]\d{1,14}\z/, message: 'Should be in e164 format' }
|
||||
format: { with: /\+[1-9]\d{1,14}\z/, message: I18n.t('errors.contacts.phone_number.invalid') }
|
||||
validates :name, length: { maximum: 255 }
|
||||
|
||||
belongs_to :account
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#
|
||||
class DataImport < ApplicationRecord
|
||||
belongs_to :account
|
||||
validates :data_type, inclusion: { in: ['contacts'], message: '%<value>s is an invalid data type' }
|
||||
validates :data_type, inclusion: { in: ['contacts'], message: I18n.t('errors.data_import.data_type.invalid') }
|
||||
enum status: { pending: 0, processing: 1, completed: 2, failed: 3 }
|
||||
|
||||
has_one_attached :import_file
|
||||
|
||||
@@ -115,13 +115,13 @@ class Inbox < ApplicationRecord
|
||||
def callback_webhook_url
|
||||
case channel_type
|
||||
when 'Channel::TwilioSms'
|
||||
"#{ENV['FRONTEND_URL']}/twilio/callback"
|
||||
"#{ENV.fetch('FRONTEND_URL', nil)}/twilio/callback"
|
||||
when 'Channel::Sms'
|
||||
"#{ENV['FRONTEND_URL']}/webhooks/sms/#{channel.phone_number.delete_prefix('+')}"
|
||||
"#{ENV.fetch('FRONTEND_URL', nil)}/webhooks/sms/#{channel.phone_number.delete_prefix('+')}"
|
||||
when 'Channel::Line'
|
||||
"#{ENV['FRONTEND_URL']}/webhooks/line/#{channel.line_channel_id}"
|
||||
"#{ENV.fetch('FRONTEND_URL', nil)}/webhooks/line/#{channel.line_channel_id}"
|
||||
when 'Channel::Whatsapp'
|
||||
"#{ENV['FRONTEND_URL']}/webhooks/whatsapp/#{channel.phone_number}"
|
||||
"#{ENV.fetch('FRONTEND_URL', nil)}/webhooks/whatsapp/#{channel.phone_number}"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
# index_installation_configs_on_name_and_created_at (name,created_at) UNIQUE
|
||||
#
|
||||
class InstallationConfig < ApplicationRecord
|
||||
# https://stackoverflow.com/questions/72970170/upgrading-to-rails-6-1-6-1-causes-psychdisallowedclass-tried-to-load-unspecif
|
||||
# https://discuss.rubyonrails.org/t/cve-2022-32224-possible-rce-escalation-bug-with-serialized-columns-in-active-record/81017
|
||||
# FIX ME : fixes breakage of installation config. we need to migrate.
|
||||
# Fix configuration in application.rb
|
||||
serialize :serialized_value, HashWithIndifferentAccess
|
||||
|
||||
before_validation :set_lock
|
||||
|
||||
@@ -28,7 +28,7 @@ class Integrations::App
|
||||
def action
|
||||
case params[:id]
|
||||
when 'slack'
|
||||
"#{params[:action]}&client_id=#{ENV['SLACK_CLIENT_ID']}&redirect_uri=#{self.class.slack_integration_url}"
|
||||
"#{params[:action]}&client_id=#{ENV.fetch('SLACK_CLIENT_ID', nil)}&redirect_uri=#{self.class.slack_integration_url}"
|
||||
else
|
||||
params[:action]
|
||||
end
|
||||
@@ -57,7 +57,7 @@ class Integrations::App
|
||||
end
|
||||
|
||||
def self.slack_integration_url
|
||||
"#{ENV['FRONTEND_URL']}/app/accounts/#{Current.account.id}/settings/integrations/slack"
|
||||
"#{ENV.fetch('FRONTEND_URL', nil)}/app/accounts/#{Current.account.id}/settings/integrations/slack"
|
||||
end
|
||||
|
||||
class << self
|
||||
|
||||
@@ -21,7 +21,7 @@ class Label < ApplicationRecord
|
||||
belongs_to :account
|
||||
|
||||
validates :title,
|
||||
presence: { message: 'must not be blank' },
|
||||
presence: { message: I18n.t('errors.validations.presence') },
|
||||
format: { with: UNICODE_CHARACTER_NUMBER_HYPHEN_UNDERSCORE },
|
||||
uniqueness: { scope: :account_id }
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ class Message < ApplicationRecord
|
||||
# move this to a presenter
|
||||
return self[:content] if !input_csat? || inbox.web_widget?
|
||||
|
||||
I18n.t('conversations.survey.response', link: "#{ENV['FRONTEND_URL']}/survey/responses/#{conversation.uuid}")
|
||||
I18n.t('conversations.survey.response', link: "#{ENV.fetch('FRONTEND_URL', nil)}/survey/responses/#{conversation.uuid}")
|
||||
end
|
||||
|
||||
def email_notifiable_message?
|
||||
|
||||
@@ -26,7 +26,7 @@ class Team < ApplicationRecord
|
||||
has_many :conversations, dependent: :nullify
|
||||
|
||||
validates :name,
|
||||
presence: { message: 'must not be blank' },
|
||||
presence: { message: I18n.t('errors.validations.presence') },
|
||||
uniqueness: { scope: :account_id }
|
||||
|
||||
before_validation do
|
||||
|
||||
@@ -73,7 +73,7 @@ class Notification::PushNotificationService
|
||||
return unless ENV['FCM_SERVER_KEY']
|
||||
return unless subscription.fcm?
|
||||
|
||||
fcm = FCM.new(ENV['FCM_SERVER_KEY'])
|
||||
fcm = FCM.new(ENV.fetch('FCM_SERVER_KEY', nil))
|
||||
response = fcm.send([subscription.subscription_attributes['push_token']], fcm_options)
|
||||
remove_subscription_if_error(subscription, response)
|
||||
end
|
||||
|
||||
@@ -31,7 +31,7 @@ class Whatsapp::Providers::Whatsapp360DialogService < Whatsapp::Providers::BaseS
|
||||
"#{api_base_path}/configs/webhook",
|
||||
headers: { 'D360-API-KEY': whatsapp_channel.provider_config['api_key'], 'Content-Type': 'application/json' },
|
||||
body: {
|
||||
url: "#{ENV['FRONTEND_URL']}/webhooks/whatsapp/#{whatsapp_channel.phone_number}"
|
||||
url: "#{ENV.fetch('FRONTEND_URL', nil)}/webhooks/whatsapp/#{whatsapp_channel.phone_number}"
|
||||
}.to_json
|
||||
)
|
||||
response.success?
|
||||
|
||||
Reference in New Issue
Block a user