Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
revert(status): restore the route default for untyped URL media
Yudhi Armyndharis12cf8370e68d
diff --git a/src/modules/status/status.service.spec.ts b/src/modules/status/status.service.spec.tsindex 188fe58f2..3b52e50ca 100644--- a/src/modules/status/status.service.spec.ts+++ b/src/modules/status/status.service.spec.ts@@ -328,35 +328,15 @@ describe('StatusService media validation and selection', () => {});});- // A URL's bytes come with the host's Content-Type, which the engines use unless the caller declared- // a type; octet-stream is the placeholder they read as "undeclared". Only base64 has nothing to go on.- it('defaults the mimetype for base64 only, and leaves an undeclared URL type to the fetched one', async () => {- const url = 'https://example.com/banner.png';+ // The status adapters fetch a URL with no fallback type of their own, so a host serving a generic+ // Content-Type would leave the bytes labelled octet-stream; the route default is the only label they get.+ it('labels an untyped URL with the route default for its kind', async () => {+ const url = 'https://example.com/banner';await service.postImageStatus('s1', { url }, { recipients: ['[email protected]'] });await service.postVideoStatus('s1', { url }, { recipients: ['[email protected]'] });- await service.postImageStatus('s1', { base64: 'QUJD' }, { recipients: ['[email protected]'] });- await service.postVideoStatus('s1', { base64: 'QUJD' }, { recipients: ['[email protected]'] });- expect(engine.postImageStatus).toHaveBeenNthCalledWith(- 1,- { mimetype: 'application/octet-stream', data: url },- expect.anything(),- );- expect(engine.postImageStatus).toHaveBeenNthCalledWith(- 2,- { mimetype: 'image/jpeg', data: 'QUJD' },- expect.anything(),- );- expect(engine.postVideoStatus).toHaveBeenNthCalledWith(- 1,- { mimetype: 'application/octet-stream', data: url },- expect.anything(),- );- expect(engine.postVideoStatus).toHaveBeenNthCalledWith(- 2,- { mimetype: 'video/mp4', data: 'QUJD' },- expect.anything(),- );+ expect(engine.postImageStatus).toHaveBeenCalledWith({ mimetype: 'image/jpeg', data: url }, expect.anything());+ expect(engine.postVideoStatus).toHaveBeenCalledWith({ mimetype: 'video/mp4', data: url }, expect.anything());});it('strips a data-URI prefix before handing base64 bytes to either engine path', async () => {diff --git a/src/modules/status/status.service.ts b/src/modules/status/status.service.tsindex 8564bf8b8..cb11945e2 100644--- a/src/modules/status/status.service.ts+++ b/src/modules/status/status.service.ts@@ -158,9 +158,7 @@ export class StatusService {() => new NotFoundException(`Session ${sessionId} not found or not connected`),);const gated = await this.gate(sessionId, 'status-image', {- // A URL with no declared type keeps the placeholder the engines read as "undeclared", so the- // fetched Content-Type labels the bytes (as on the chat path); the route default is for base64.- media: { mimetype: mimetype ?? (base64 ? 'image/jpeg' : 'application/octet-stream'), data: base64 || url || '' },+ media: { mimetype: mimetype ?? 'image/jpeg', data: base64 || url || '' },options,});return this.recordedPost(sessionId, () => engine.postImageStatus(this.guardGatedMedia(gated.media), gated.options));@@ -183,7 +181,7 @@ export class StatusService {() => new NotFoundException(`Session ${sessionId} not found or not connected`),);const gated = await this.gate(sessionId, 'status-video', {- media: { mimetype: mimetype ?? (base64 ? 'video/mp4' : 'application/octet-stream'), data: base64 || url || '' },+ media: { mimetype: mimetype ?? 'video/mp4', data: base64 || url || '' },options,});return this.recordedPost(sessionId, () => engine.postVideoStatus(this.guardGatedMedia(gated.media), gated.options));