diff --git a/.env.example b/.env.example index cc7e1c2dd..d46acac9f 100644 --- a/.env.example +++ b/.env.example @@ -161,13 +161,15 @@ USE_INBOX_AVATAR_FOR_BOT=true ## NewRelic # https://docs.newrelic.com/docs/agents/ruby-agent/configuration/ruby-agent-configuration/ # NEW_RELIC_LICENSE_KEY= +# Set this to true to allow newrelic apm to send logs. +# This is turned off by default. +# NEW_RELIC_APPLICATION_LOGGING_ENABLED= ## Datadog ## https://github.com/DataDog/dd-trace-rb/blob/master/docs/GettingStarted.md#environment-variables # DD_TRACE_AGENT_URL= - ## IP look up configuration ## ref https://github.com/alexreisner/geocoder/blob/master/README_API_GUIDE.md ## works only on accounts with ip look up feature enabled diff --git a/Gemfile.lock b/Gemfile.lock index ba8f04ec9..1e2147bc1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -376,7 +376,7 @@ GEM net-http-persistent (4.0.1) connection_pool (~> 2.2) netrc (0.11.0) - newrelic_rpm (8.4.0) + newrelic_rpm (8.7.0) nio4r (2.5.8) nokogiri (1.13.4) mini_portile2 (~> 2.8.0) diff --git a/app/builders/contact_builder.rb b/app/builders/contact_builder.rb index b63d72627..10ce8ee26 100644 --- a/app/builders/contact_builder.rb +++ b/app/builders/contact_builder.rb @@ -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 diff --git a/app/builders/messages/facebook/message_builder.rb b/app/builders/messages/facebook/message_builder.rb index 204b452d6..9c9b5829b 100644 --- a/app/builders/messages/facebook/message_builder.rb +++ b/app/builders/messages/facebook/message_builder.rb @@ -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 diff --git a/app/channels/room_channel.rb b/app/channels/room_channel.rb index 05bff5d86..0680f1458 100644 --- a/app/channels/room_channel.rb +++ b/app/channels/room_channel.rb @@ -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 diff --git a/app/controllers/api/v1/accounts/channels/twilio_channels_controller.rb b/app/controllers/api/v1/accounts/channels/twilio_channels_controller.rb index a53650e65..f5a3c6a6d 100644 --- a/app/controllers/api/v1/accounts/channels/twilio_channels_controller.rb +++ b/app/controllers/api/v1/accounts/channels/twilio_channels_controller.rb @@ -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 diff --git a/app/controllers/api/v1/accounts/conversations/base_controller.rb b/app/controllers/api/v1/accounts/conversations/base_controller.rb index b55b72013..da821a3e5 100644 --- a/app/controllers/api/v1/accounts/conversations/base_controller.rb +++ b/app/controllers/api/v1/accounts/conversations/base_controller.rb @@ -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 diff --git a/app/finders/message_finder.rb b/app/finders/message_finder.rb index 63c72bd8e..e2581e0ad 100644 --- a/app/finders/message_finder.rb +++ b/app/finders/message_finder.rb @@ -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 diff --git a/app/javascript/dashboard/components/layout/Sidebar.vue b/app/javascript/dashboard/components/layout/Sidebar.vue index c7fda74f1..5017b3d4b 100644 --- a/app/javascript/dashboard/components/layout/Sidebar.vue +++ b/app/javascript/dashboard/components/layout/Sidebar.vue @@ -19,6 +19,7 @@ :menu-config="activeSecondaryMenu" :current-role="currentRole" @add-label="showAddLabelPopup" + @toggle-accounts="toggleAccountModal" /> diff --git a/app/javascript/dashboard/components/layout/sidebarComponents/AccountContext.vue b/app/javascript/dashboard/components/layout/sidebarComponents/AccountContext.vue index 1438ac7e8..71382d5e6 100644 --- a/app/javascript/dashboard/components/layout/sidebarComponents/AccountContext.vue +++ b/app/javascript/dashboard/components/layout/sidebarComponents/AccountContext.vue @@ -1,14 +1,34 @@ diff --git a/app/javascript/dashboard/components/layout/sidebarComponents/Secondary.vue b/app/javascript/dashboard/components/layout/sidebarComponents/Secondary.vue index 8d486a454..724576347 100644 --- a/app/javascript/dashboard/components/layout/sidebarComponents/Secondary.vue +++ b/app/javascript/dashboard/components/layout/sidebarComponents/Secondary.vue @@ -1,6 +1,6 @@