Fix incoming Signal messages when conversation initiated from Zammad
This commit is contained in:
parent
46e1116bc5
commit
20ef676cf1
6 changed files with 27 additions and 11 deletions
|
|
@ -213,11 +213,12 @@ class ChannelsCdrSignalController < ApplicationController
|
|||
Rails.logger.info "Channel ID: #{channel.id}"
|
||||
|
||||
begin
|
||||
all_tickets = Ticket.where(customer_id: customer.id)
|
||||
.where.not(state_id: state_ids)
|
||||
# For group messages, search all tickets regardless of customer
|
||||
# since users may have duplicate phone numbers
|
||||
all_tickets = Ticket.where.not(state_id: state_ids)
|
||||
.order(updated_at: :desc)
|
||||
|
||||
Rails.logger.info "Found #{all_tickets.count} active tickets for customer"
|
||||
Rails.logger.info "Found #{all_tickets.count} active tickets (searching all customers for group match)"
|
||||
|
||||
ticket = all_tickets.find do |t|
|
||||
begin
|
||||
|
|
@ -247,6 +248,11 @@ class ChannelsCdrSignalController < ApplicationController
|
|||
|
||||
if ticket
|
||||
Rails.logger.info "=== FOUND MATCHING TICKET BY GROUP ID: ##{ticket.number} ==="
|
||||
# Update customer if different (handles duplicate phone numbers)
|
||||
if ticket.customer_id != customer.id
|
||||
Rails.logger.info "Updating ticket customer from #{ticket.customer_id} to #{customer.id}"
|
||||
ticket.customer_id = customer.id
|
||||
end
|
||||
else
|
||||
Rails.logger.info "=== NO MATCHING TICKET BY GROUP ID - CHECKING BY PHONE NUMBER ==="
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ class CommunicateCdrSignalJob < ApplicationJob
|
|||
log_error(article,
|
||||
"Can't find ticket.preferences['cdr_signal']['bot_token'] for Ticket.find(#{article.ticket_id})")
|
||||
end
|
||||
unless ticket.preferences['cdr_signal']['chat_id']
|
||||
# Only require chat_id if auto-groups is not enabled
|
||||
if ENV['BRIDGE_SIGNAL_AUTO_GROUPS'].to_s.downcase != 'true' && ticket.preferences['cdr_signal']['chat_id'].blank?
|
||||
log_error(article,
|
||||
"Can't find ticket.preferences['cdr_signal']['chat_id'] for Ticket.find(#{article.ticket_id})")
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue