chore: Fix sentry issues (#4863)
Fix sentry issues. Fixes #4815, #4814, #4811, #4809
This commit is contained in:
parent
067c905329
commit
9015d83679
6 changed files with 51 additions and 12 deletions
|
@ -43,14 +43,18 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@inbox.update!(permitted_params.except(:channel))
|
@inbox.update!(permitted_params.except(:channel))
|
||||||
@inbox.update_working_hours(params.permit(working_hours: Inbox::OFFISABLE_ATTRS)[:working_hours]) if params[:working_hours]
|
update_inbox_working_hours
|
||||||
channel_attributes = get_channel_attributes(@inbox.channel_type)
|
channel_attributes = get_channel_attributes(@inbox.channel_type)
|
||||||
|
|
||||||
# Inbox update doesn't necessarily need channel attributes
|
# Inbox update doesn't necessarily need channel attributes
|
||||||
return if permitted_params(channel_attributes)[:channel].blank?
|
return if permitted_params(channel_attributes)[:channel].blank?
|
||||||
|
|
||||||
if @inbox.inbox_type == 'Email'
|
if @inbox.inbox_type == 'Email'
|
||||||
validate_email_channel(channel_attributes)
|
begin
|
||||||
|
validate_email_channel(channel_attributes)
|
||||||
|
rescue StandardError => e
|
||||||
|
render json: { message: e }, status: :unprocessable_entity and return
|
||||||
|
end
|
||||||
@inbox.channel.reauthorized!
|
@inbox.channel.reauthorized!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,6 +62,10 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController
|
||||||
update_channel_feature_flags
|
update_channel_feature_flags
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_inbox_working_hours
|
||||||
|
@inbox.update_working_hours(params.permit(working_hours: Inbox::OFFISABLE_ATTRS)[:working_hours]) if params[:working_hours]
|
||||||
|
end
|
||||||
|
|
||||||
def agent_bot
|
def agent_bot
|
||||||
@agent_bot = @inbox.agent_bot
|
@agent_bot = @inbox.agent_bot
|
||||||
end
|
end
|
||||||
|
@ -89,12 +97,6 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController
|
||||||
@agent_bot = AgentBot.find(params[:agent_bot]) if params[:agent_bot]
|
@agent_bot = AgentBot.find(params[:agent_bot]) if params[:agent_bot]
|
||||||
end
|
end
|
||||||
|
|
||||||
def inbox_name(channel)
|
|
||||||
return channel.try(:bot_name) if channel.is_a?(Channel::Telegram)
|
|
||||||
|
|
||||||
permitted_params[:name]
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_channel
|
def create_channel
|
||||||
return unless %w[web_widget api email line telegram whatsapp sms].include?(permitted_params[:channel][:type])
|
return unless %w[web_widget api email line telegram whatsapp sms].include?(permitted_params[:channel][:type])
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
module Api::V1::InboxesHelper
|
module Api::V1::InboxesHelper
|
||||||
|
def inbox_name(channel)
|
||||||
|
return channel.try(:bot_name) if channel.is_a?(Channel::Telegram)
|
||||||
|
|
||||||
|
permitted_params[:name]
|
||||||
|
end
|
||||||
|
|
||||||
def validate_email_channel(attributes)
|
def validate_email_channel(attributes)
|
||||||
channel_data = permitted_params(attributes)[:channel]
|
channel_data = permitted_params(attributes)[:channel]
|
||||||
|
|
||||||
|
@ -19,8 +25,7 @@ module Api::V1::InboxesHelper
|
||||||
enable_ssl: channel_data[:imap_enable_ssl] }
|
enable_ssl: channel_data[:imap_enable_ssl] }
|
||||||
end
|
end
|
||||||
|
|
||||||
Mail.connection do # rubocop:disable:block
|
check_imap_connection(channel_data)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_smtp(channel_data)
|
def validate_smtp(channel_data)
|
||||||
|
@ -32,6 +37,25 @@ module Api::V1::InboxesHelper
|
||||||
check_smtp_connection(channel_data, smtp)
|
check_smtp_connection(channel_data, smtp)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_imap_connection(channel_data)
|
||||||
|
Mail.connection {} # rubocop:disable:block
|
||||||
|
rescue SocketError => e
|
||||||
|
raise StandardError, I18n.t('errors.inboxes.imap.socket_error')
|
||||||
|
rescue Net::IMAP::NoResponseError => e
|
||||||
|
raise StandardError, I18n.t('errors.inboxes.imap.no_response_error')
|
||||||
|
rescue Errno::EHOSTUNREACH => e
|
||||||
|
raise StandardError, I18n.t('errors.inboxes.imap.host_unreachable_error')
|
||||||
|
rescue Net::OpenTimeout => e
|
||||||
|
raise StandardError,
|
||||||
|
I18n.t('errors.inboxes.imap.connection_timed_out_error', address: channel_data[:imap_address], port: channel_data[:imap_port])
|
||||||
|
rescue Net::IMAP::Error => e
|
||||||
|
raise StandardError, I18n.t('errors.inboxes.imap.connection_closed_error')
|
||||||
|
rescue StandardError => e
|
||||||
|
raise StandardError, e.message
|
||||||
|
ensure
|
||||||
|
Rails.logger.error e if e.present?
|
||||||
|
end
|
||||||
|
|
||||||
def check_smtp_connection(channel_data, smtp)
|
def check_smtp_connection(channel_data, smtp)
|
||||||
smtp.start(channel_data[:smtp_domain], channel_data[:smtp_login], channel_data[:smtp_password],
|
smtp.start(channel_data[:smtp_domain], channel_data[:smtp_login], channel_data[:smtp_password],
|
||||||
channel_data[:smtp_authentication]&.to_sym || :login)
|
channel_data[:smtp_authentication]&.to_sym || :login)
|
||||||
|
|
|
@ -156,7 +156,7 @@ export default {
|
||||||
await this.$store.dispatch('inboxes/updateInboxIMAP', payload);
|
await this.$store.dispatch('inboxes/updateInboxIMAP', payload);
|
||||||
this.showAlert(this.$t('INBOX_MGMT.IMAP.EDIT.SUCCESS_MESSAGE'));
|
this.showAlert(this.$t('INBOX_MGMT.IMAP.EDIT.SUCCESS_MESSAGE'));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.showAlert(this.$t('INBOX_MGMT.IMAP.EDIT.ERROR_MESSAGE'));
|
this.showAlert(error.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -216,7 +216,11 @@ export const actions = {
|
||||||
commit(types.default.SET_INBOXES_UI_FLAG, {
|
commit(types.default.SET_INBOXES_UI_FLAG, {
|
||||||
isUpdatingIMAP: false,
|
isUpdatingIMAP: false,
|
||||||
});
|
});
|
||||||
throw new Error(error);
|
if (error.response?.data?.message) {
|
||||||
|
throw new Error(error.response?.data?.message);
|
||||||
|
} else {
|
||||||
|
throw new Error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateInboxSMTP: async (
|
updateInboxSMTP: async (
|
||||||
|
|
|
@ -21,6 +21,8 @@ module MailboxHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_attachments_to_message
|
def add_attachments_to_message
|
||||||
|
return if @message.blank?
|
||||||
|
|
||||||
processed_mail.attachments.each do |mail_attachment|
|
processed_mail.attachments.each do |mail_attachment|
|
||||||
attachment = @message.attachments.new(
|
attachment = @message.attachments.new(
|
||||||
account_id: @conversation.account_id,
|
account_id: @conversation.account_id,
|
||||||
|
|
|
@ -46,6 +46,13 @@ en:
|
||||||
contacts:
|
contacts:
|
||||||
import:
|
import:
|
||||||
failed: File is blank
|
failed: File is blank
|
||||||
|
inboxes:
|
||||||
|
imap:
|
||||||
|
socket_error: Please check the network connection, IMAP address and try again.
|
||||||
|
no_response_error: Please check the IMAP credentials and try again.
|
||||||
|
host_unreachable_error: Host unreachable, Please check the IMAP address, IMAP port and try again.
|
||||||
|
connection_timed_out_error: Connection timed out for %{address}:%{port}
|
||||||
|
connection_closed_error: Connection closed.
|
||||||
|
|
||||||
reports:
|
reports:
|
||||||
period: Reporting period %{since} to %{until}
|
period: Reporting period %{since} to %{until}
|
||||||
|
|
Loading…
Reference in a new issue