diff --git a/app/jobs/action_cable_broadcast_job.rb b/app/jobs/action_cable_broadcast_job.rb index 74dab618d..a8fd83e44 100644 --- a/app/jobs/action_cable_broadcast_job.rb +++ b/app/jobs/action_cable_broadcast_job.rb @@ -25,9 +25,17 @@ class ActionCableBroadcastJob < ApplicationJob def prepare_broadcast_data(event_name, data) return data unless CONVERSATION_UPDATE_EVENTS.include?(event_name) - account = Account.find(data[:account_id]) - conversation = account.conversations.find_by!(display_id: data[:id]) - conversation.push_event_data.merge(account_id: data[:account_id]) + account_id = data[:account_id] + display_id = data[:id] + return data if account_id.blank? || display_id.blank? + + account = Account.find_by(id: account_id) + return data if account.blank? + + conversation = account.conversations.find_by(display_id: display_id) + return data if conversation.blank? + + conversation.push_event_data.merge(account_id: account_id) end def broadcast_to_members(members, event_name, broadcast_data) diff --git a/app/models/integrations/hook.rb b/app/models/integrations/hook.rb index 97d3f91ae..e46db43be 100644 --- a/app/models/integrations/hook.rb +++ b/app/models/integrations/hook.rb @@ -89,7 +89,10 @@ class Integrations::Hook < ApplicationRecord end def ensure_hook_type - self.hook_type = app.params[:hook_type] if app.present? + return if app.blank? + return unless new_record? || hook_type.blank? + + self.hook_type = app.params[:hook_type] end def validate_settings_json_schema diff --git a/app/services/crm/leadsquared/setup_service.rb b/app/services/crm/leadsquared/setup_service.rb index 0433f68fd..12117115b 100644 --- a/app/services/crm/leadsquared/setup_service.rb +++ b/app/services/crm/leadsquared/setup_service.rb @@ -82,7 +82,7 @@ class Crm::Leadsquared::SetupService end def update_hook_settings(params) - @hook.settings = @hook.settings.merge(params) + @hook.settings = @hook.settings.merge(params.stringify_keys) @hook.save! end