From 48aa534edbdeef4655f521e933ea99574c014a16 Mon Sep 17 00:00:00 2001 From: gioelecerati Date: Tue, 16 Apr 2024 10:00:47 +0200 Subject: [PATCH] api: gate: add playurl to logs --- .../api/src/controllers/access-control.ts | 48 +++++++++++++------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/packages/api/src/controllers/access-control.ts b/packages/api/src/controllers/access-control.ts index 5d8f872444..9e74c6d634 100644 --- a/packages/api/src/controllers/access-control.ts +++ b/packages/api/src/controllers/access-control.ts @@ -116,22 +116,40 @@ async function fireGateWebhook( ); } if ("pull" in content && content.pull) { - let referer: string, origin: string; - if (payload?.webhookPayload?.headers) { - referer = payload?.webhookPayload?.headers["Referer"]; - origin = payload?.webhookPayload?.headers["Origin"]; + try { + let referer: string, origin: string; + if (payload?.webhookPayload?.headers) { + referer = payload?.webhookPayload?.headers["Referer"]; + origin = payload?.webhookPayload?.headers["Origin"]; + } + let playURL = payload?.webhookPayload?.playURL; + let playDomain = payload?.webhookPayload?.playDomain; + console.log( + `access-control: gate: webhook=${ + webhook.id + } statusCode=${statusCode} respSpanId=${resp?.headers.get( + "X-Tlive-Spanid" + )} respBody=${Buffer.from(respBody).toString("base64")} duration=${ + process.hrtime(startTime)[1] / 1e6 + }ms accessKey=${payload.accessKey} playbackId=${ + content.playbackId + } webhook=${ + webhook.id + } referer=${referer} origin=${origin} playURL=${playURL} playDomain=${playDomain}` + ); + } catch (e) { + console.log( + `access-control: gate: webhook=${ + webhook.id + } statusCode=${statusCode} respSpanId=${resp?.headers.get( + "X-Tlive-Spanid" + )} respBody=${Buffer.from(respBody).toString("base64")} duration=${ + process.hrtime(startTime)[1] / 1e6 + }ms accessKey=${payload.accessKey} playbackId=${ + content.playbackId + } webhook=${webhook.id}` + ); } - console.log( - `access-control: gate: webhook=${ - webhook.id - } statusCode=${statusCode} respSpanId=${resp?.headers.get( - "X-Tlive-Spanid" - )} respBody=${Buffer.from(respBody).toString("base64")} duration=${ - process.hrtime(startTime)[1] / 1e6 - }ms accessKey=${payload.accessKey} playbackId=${ - content.playbackId - } webhook=${webhook.id} referer=${referer} origin=${origin}` - ); } else { console.log( `access-control: gate: webhook=${