Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

feat(baileys): implement deleteStatus via constructed revoke key (best-effort)

yudhi444d0d610435
diff --git a/src/engine/adapters/baileys.adapter.spec.ts b/src/engine/adapters/baileys.adapter.spec.ts
index 257758e4c..1c57dcc46 100644
--- a/src/engine/adapters/baileys.adapter.spec.ts
+++ b/src/engine/adapters/baileys.adapter.spec.ts
@@ -1735,4 +1735,19 @@ describe('BaileysAdapter status posting', () => {
{ statusJidList: ['[email protected]'], backgroundColor: undefined, font: undefined },
);
});
+
+ it('deleteStatus revokes by constructing the key from statusId (no store lookup)', async () => {
+ fakeSock.sendMessage.mockResolvedValue({ key: { id: 'STATUS1' } });
+ const adapter = await ready();
+ await adapter.deleteStatus('STATUS1');
+ expect(fakeSock.sendMessage).toHaveBeenCalledWith('status@broadcast', {
+ delete: {
+ remoteJid: 'status@broadcast',
+ fromMe: true,
+ id: 'STATUS1',
+ participant: '[email protected]',
+ },
+ });
+ expect(fakeStore.getMessage).not.toHaveBeenCalled();
+ });
});
diff --git a/src/engine/adapters/baileys.adapter.ts b/src/engine/adapters/baileys.adapter.ts
index 9d953e111..2b185e787 100644
--- a/src/engine/adapters/baileys.adapter.ts
+++ b/src/engine/adapters/baileys.adapter.ts
@@ -819,8 +819,22 @@ export class BaileysAdapter implements IWhatsAppEngine {
: { video: data, caption: options.caption, mimetype };
return this.postStatus(content, options);
}
- deleteStatus(_statusId: string): Promise<void> {
- return this.unsupported('deleteStatus');
+ /**
+ * Best-effort status revoke. Unlike deleteMessage, status messages are NOT persisted, so the revoke
+ * key must be constructed from statusId alone (no messageStore lookup). The participant is the
+ * engine-dialect self JID (`<me>@s.whatsapp.net`). The revoke shape is empirically UNVERIFIED — the
+ * live spike only tested posting; if WhatsApp rejects it, fall back to EngineNotSupportedError.
+ */
+ async deleteStatus(statusId: string): Promise<void> {
+ this.ensureReady();
+ await this.sock!.sendMessage('status@broadcast', {
+ delete: {
+ remoteJid: 'status@broadcast',
+ fromMe: true,
+ id: statusId,
+ participant: this.sessionStore.toEngineJid(this.normalizedSelfJid()),
+ },
+ });
}
getCatalog(): Promise<Catalog | null> {
return this.unsupported('getCatalog');