mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-08 06:54:24 +00:00
fix: narrow webhook event provider call id typing
This commit is contained in:
@@ -110,19 +110,18 @@ export function processEvent(ctx: EventContext, event: NormalizedEvent): void {
|
||||
callIdOrProviderCallId: event.callId,
|
||||
});
|
||||
|
||||
const providerCallId = event.providerCallId;
|
||||
const eventDirection =
|
||||
event.direction === "inbound" || event.direction === "outbound" ? event.direction : undefined;
|
||||
|
||||
// Auto-register untracked calls arriving via webhook. This covers both
|
||||
// true inbound calls and externally-initiated outbound-api calls (e.g. calls
|
||||
// placed directly via the Twilio REST API pointing at our webhook URL).
|
||||
const isUnregisteredWebhookCall =
|
||||
!call &&
|
||||
event.providerCallId &&
|
||||
(event.direction === "inbound" || event.direction === "outbound");
|
||||
|
||||
if (isUnregisteredWebhookCall) {
|
||||
if (!call && providerCallId && eventDirection) {
|
||||
// Apply inbound policy for true inbound calls; external outbound-api calls
|
||||
// are implicitly trusted because the caller controls the webhook URL.
|
||||
if (event.direction === "inbound" && !shouldAcceptInbound(ctx.config, event.from)) {
|
||||
const pid = event.providerCallId;
|
||||
if (eventDirection === "inbound" && !shouldAcceptInbound(ctx.config, event.from)) {
|
||||
const pid = providerCallId;
|
||||
if (!ctx.provider) {
|
||||
console.warn(
|
||||
`[voice-call] Inbound call rejected by policy but no provider to hang up (providerCallId: ${pid}, from: ${event.from}); call will time out on provider side.`,
|
||||
@@ -150,8 +149,8 @@ export function processEvent(ctx: EventContext, event: NormalizedEvent): void {
|
||||
|
||||
call = createWebhookCall({
|
||||
ctx,
|
||||
providerCallId: event.providerCallId,
|
||||
direction: event.direction === "outbound" ? "outbound" : "inbound",
|
||||
providerCallId,
|
||||
direction: eventDirection === "outbound" ? "outbound" : "inbound",
|
||||
from: event.from || "unknown",
|
||||
to: event.to || ctx.config.fromNumber || "unknown",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user