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
|
||||
|
||||
def create_contact_inbox(contact)
|
||||
::ContactInbox.create!(
|
||||
::ContactInbox.create_with(hmac_verified: hmac_verified || false).find_or_create_by!(
|
||||
contact_id: contact.id,
|
||||
inbox_id: inbox.id,
|
||||
source_id: source_id,
|
||||
hmac_verified: hmac_verified || false
|
||||
source_id: source_id
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class Messages::Facebook::MessageBuilder < Messages::Messenger::MessageBuilder
|
|||
return if contact.present?
|
||||
|
||||
@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
|
||||
|
||||
def build_message
|
||||
|
|
|
@ -45,6 +45,8 @@ class RoomChannel < ApplicationCable::Channel
|
|||
end
|
||||
|
||||
def current_account
|
||||
return if current_user.blank?
|
||||
|
||||
@current_account ||= if @current_user.is_a? Contact
|
||||
@current_user.account
|
||||
else
|
||||
|
|
|
@ -7,7 +7,6 @@ class Api::V1::Accounts::Channels::TwilioChannelsController < Api::V1::Accounts:
|
|||
build_inbox
|
||||
setup_webhooks if @twilio_channel.sms?
|
||||
rescue StandardError => e
|
||||
Sentry.capture_exception(e)
|
||||
render_could_not_create_error(e.message)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ class Api::V1::Accounts::Conversations::BaseController < Api::V1::Accounts::Base
|
|||
private
|
||||
|
||||
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?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ class MessageFinder
|
|||
|
||||
def current_messages
|
||||
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
|
||||
messages.reorder('created_at desc').limit(20).reverse
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ class HookJob < ApplicationJob
|
|||
process_dialogflow_integration(hook, event_name, event_data)
|
||||
end
|
||||
rescue StandardError => e
|
||||
Sentry.capture_exception(e)
|
||||
Rails.logger.error e
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -7,7 +7,7 @@ class Webhooks::Trigger
|
|||
timeout: 5
|
||||
)
|
||||
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}"
|
||||
rescue StandardError => e
|
||||
Rails.logger.error "Exception: invalid webhook url #{url} : #{e.message}"
|
||||
|
|
Loading…
Reference in a new issue