Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

refactor(wwebjs): type group creation and drop phantom fields

Yudhi Armyndharis6faa92a707e6
diff --git a/src/engine/adapters/baileys-group-mapper.ts b/src/engine/adapters/baileys-group-mapper.ts
index d5aa33cde..78a1b036b 100644
--- a/src/engine/adapters/baileys-group-mapper.ts
+++ b/src/engine/adapters/baileys-group-mapper.ts
@@ -79,9 +79,9 @@ export function mapBaileysGroupInfo(
createdAt: metadata.creation,
participants,
// WhatsApp "announce" = only admins can post. isAnnounce reports the group SETTING; isReadOnly
- // reports what it means for THIS account, which is the question whatsapp-web.js answers with WA
- // Web's own per-account flag. Copying announce into both told an admin of an announce-only group
- // that they could not post, in the one field a client uses to disable its composer.
+ // reports what it means for THIS account. Copying announce into both told an admin of an
+ // announce-only group that they could not post, in the one field a client uses to disable its
+ // composer.
isAnnounce: metadata.announce,
isReadOnly: selfJid
? Boolean(metadata.announce) && !isSelfAdmin(metadata, selfJid, normalizeJid)
diff --git a/src/engine/types/whatsapp-web-js.types.ts b/src/engine/types/whatsapp-web-js.types.ts
index c1110d996..ff6e81eb3 100644
--- a/src/engine/types/whatsapp-web-js.types.ts
+++ b/src/engine/types/whatsapp-web-js.types.ts
@@ -45,6 +45,8 @@ export interface GroupMetadataRaw {
restrict?: boolean;
/** Disappearing-messages timer in seconds, when WA Web reports one on the group model. */
ephemeralDuration?: number;
+ /** Unix seconds the group was created (WA Web group model). */
+ creation?: number;
/**
* Who may add participants. Typed loosely on purpose: whatsapp-web.js declares this `boolean`
* (index.d.ts:890, documented as "true = only admins") but actually writes WhatsApp's raw strings
@@ -66,9 +68,7 @@ export interface GroupChat extends Omit<Chat, 'isReadOnly' | 'getLabels'> {
}>;
description?: string;
owner?: { _serialized: string };
- createdAt?: number;
isReadOnly?: boolean;
- isAnnounce?: boolean;
groupMetadata?: GroupMetadataRaw;
addParticipants(
ids: string[],