chore: Sentry issues (#4623)
Fixes various issues reported on sentry - Twilio channel creation validation errors - Room Channel error with nil class - Webhook Uri exception
This commit is contained in:
parent
4f9d41962a
commit
8d2b719dc1
8 changed files with 9 additions and 9 deletions
|
@ -15,11 +15,10 @@ class ContactBuilder
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_contact_inbox(contact)
|
def create_contact_inbox(contact)
|
||||||
::ContactInbox.create!(
|
::ContactInbox.create_with(hmac_verified: hmac_verified || false).find_or_create_by!(
|
||||||
contact_id: contact.id,
|
contact_id: contact.id,
|
||||||
inbox_id: inbox.id,
|
inbox_id: inbox.id,
|
||||||
source_id: source_id,
|
source_id: source_id
|
||||||
hmac_verified: hmac_verified || false
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Messages::Facebook::MessageBuilder < Messages::Messenger::MessageBuilder
|
||||||
return if contact.present?
|
return if contact.present?
|
||||||
|
|
||||||
@contact = Contact.create!(contact_params.except(:remote_avatar_url))
|
@contact = Contact.create!(contact_params.except(:remote_avatar_url))
|
||||||
@contact_inbox = ContactInbox.create(contact: contact, inbox: @inbox, source_id: @sender_id)
|
@contact_inbox = ContactInbox.find_or_create_by!(contact: contact, inbox: @inbox, source_id: @sender_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_message
|
def build_message
|
||||||
|
|
|
@ -45,6 +45,8 @@ class RoomChannel < ApplicationCable::Channel
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_account
|
def current_account
|
||||||
|
return if current_user.blank?
|
||||||
|
|
||||||
@current_account ||= if @current_user.is_a? Contact
|
@current_account ||= if @current_user.is_a? Contact
|
||||||
@current_user.account
|
@current_user.account
|
||||||
else
|
else
|
||||||
|
|
|
@ -7,7 +7,6 @@ class Api::V1::Accounts::Channels::TwilioChannelsController < Api::V1::Accounts:
|
||||||
build_inbox
|
build_inbox
|
||||||
setup_webhooks if @twilio_channel.sms?
|
setup_webhooks if @twilio_channel.sms?
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Sentry.capture_exception(e)
|
|
||||||
render_could_not_create_error(e.message)
|
render_could_not_create_error(e.message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Api::V1::Accounts::Conversations::BaseController < Api::V1::Accounts::Base
|
||||||
private
|
private
|
||||||
|
|
||||||
def conversation
|
def conversation
|
||||||
@conversation ||= Current.account.conversations.find_by(display_id: params[:conversation_id])
|
@conversation ||= Current.account.conversations.find_by!(display_id: params[:conversation_id])
|
||||||
authorize @conversation.inbox, :show?
|
authorize @conversation.inbox, :show?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,7 +22,7 @@ class MessageFinder
|
||||||
|
|
||||||
def current_messages
|
def current_messages
|
||||||
if @params[:before].present?
|
if @params[:before].present?
|
||||||
messages.reorder('created_at desc').where('id < ?', @params[:before]).limit(20).reverse
|
messages.reorder('created_at desc').where('id < ?', @params[:before].to_i).limit(20).reverse
|
||||||
else
|
else
|
||||||
messages.reorder('created_at desc').limit(20).reverse
|
messages.reorder('created_at desc').limit(20).reverse
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ class HookJob < ApplicationJob
|
||||||
process_dialogflow_integration(hook, event_name, event_data)
|
process_dialogflow_integration(hook, event_name, event_data)
|
||||||
end
|
end
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Sentry.capture_exception(e)
|
Rails.logger.error e
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -7,7 +7,7 @@ class Webhooks::Trigger
|
||||||
timeout: 5
|
timeout: 5
|
||||||
)
|
)
|
||||||
Rails.logger.info "Performed Request: Code - #{response.code}"
|
Rails.logger.info "Performed Request: Code - #{response.code}"
|
||||||
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS => e
|
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS, URI::InvalidURIError => e
|
||||||
Rails.logger.error "Exception: invalid webhook url #{url} : #{e.message}"
|
Rails.logger.error "Exception: invalid webhook url #{url} : #{e.message}"
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Rails.logger.error "Exception: invalid webhook url #{url} : #{e.message}"
|
Rails.logger.error "Exception: invalid webhook url #{url} : #{e.message}"
|
||||||
|
|
Loading…
Reference in a new issue