From 151ea806dd5fe7c316a4679539fd07305117d0ff Mon Sep 17 00:00:00 2001 From: CrazyBolillo Date: Sun, 20 Oct 2024 18:27:54 -0600 Subject: [PATCH] feat: support external callers When receiving calls from external callers (usually from PSTN) the endpoint won't be found, this would previously result in calls not being allowed. The logic has been changed to support this use case. --- internal/service/bouncer.go | 9 ++++++++- internal/sqlc/queries.sql.go | 2 +- queries.sql | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/service/bouncer.go b/internal/service/bouncer.go index 5313000..e2f4ffe 100644 --- a/internal/service/bouncer.go +++ b/internal/service/bouncer.go @@ -32,9 +32,16 @@ func (b *Bouncer) Check(ctx context.Context, endpoint, dialed string) model.Boun return result } + var callerId string + if row.Callerid.Valid { + callerId = row.Callerid.String + } else { + callerId = endpoint + } + return model.BouncerResponse{ Allow: true, Destination: row.ID, - CallerID: row.Callerid.String, + CallerID: callerId, } } diff --git a/internal/sqlc/queries.sql.go b/internal/sqlc/queries.sql.go index 2d4dcf1..9e3d93e 100644 --- a/internal/sqlc/queries.sql.go +++ b/internal/sqlc/queries.sql.go @@ -84,7 +84,7 @@ FROM ps_endpoints dest INNER JOIN ery_extension ee ON dest.sid = ee.endpoint_id -INNER JOIN +LEFT JOIN ps_endpoints src ON src.id = $1 WHERE ee.extension = $2 diff --git a/queries.sql b/queries.sql index deb038a..4e5a589 100644 --- a/queries.sql +++ b/queries.sql @@ -63,7 +63,7 @@ FROM ps_endpoints dest INNER JOIN ery_extension ee ON dest.sid = ee.endpoint_id -INNER JOIN +LEFT JOIN ps_endpoints src ON src.id = $1 WHERE ee.extension = $2;