fix(twilio): fall back to phone lookup when MessagingServiceSid is unknown
Twilio includes `MessagingServiceSid` on inbound webhooks whenever the number is part of a Messaging Service pool on Twilio's side (required for US A2P 10DLC), even for Chatwoot channels registered by phone number alone. The signature-verify concern was rejecting those webhooks with 403 because lookup-by-MSS returned nil and did not fall through. Only reject outright when the MSS does resolve to a channel but the AccountSid mismatches — the cross-tenant guard from the earlier review is preserved.
This commit is contained in:
@@ -52,9 +52,11 @@ module TwilioSignatureVerifyConcern
|
||||
def find_twilio_channel
|
||||
if params[:MessagingServiceSid].present?
|
||||
channel = ::Channel::TwilioSms.find_by(messaging_service_sid: params[:MessagingServiceSid])
|
||||
return channel if channel.present? && (params[:AccountSid].blank? || channel.account_sid == params[:AccountSid])
|
||||
if channel.present?
|
||||
return channel if params[:AccountSid].blank? || channel.account_sid == params[:AccountSid]
|
||||
|
||||
return nil
|
||||
return nil
|
||||
end
|
||||
end
|
||||
return if params[:AccountSid].blank?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user