From 49e7ad4b258026c2368e8a61bc76174e190a4bbd Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Tue, 7 Dec 2021 22:09:18 +0530 Subject: [PATCH] fix: typeerror on some group create --- src/Socket/groups.ts | 4 ++-- src/Socket/messages-recv.ts | 4 +--- src/Types/GroupMetadata.ts | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Socket/groups.ts b/src/Socket/groups.ts index b002534..11a16a1 100644 --- a/src/Socket/groups.ts +++ b/src/Socket/groups.ts @@ -1,6 +1,6 @@ import { generateMessageID } from "../Utils"; import { SocketConfig, GroupMetadata, ParticipantAction } from "../Types"; -import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, jidEncode } from "../WABinary"; +import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, jidEncode, jidNormalizedUser } from "../WABinary"; import { makeSocket } from "./socket"; export const makeGroupsSocket = (config: SocketConfig) => { @@ -196,7 +196,7 @@ export const extractGroupMetadata = (result: BinaryNode) => { id: groupId, subject: group.attrs.subject, creation: +group.attrs.creation, - owner: group.attrs.creator, + owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined, desc, descId, restrict: !!getBinaryNodeChild(result, 'locked'), diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index 218b7f8..3db993a 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -274,9 +274,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { result.messageStubType = WAMessageStubType.GROUP_CREATE result.messageStubParameters = [metadata.subject] - result.key = { - participant: jidNormalizedUser(metadata.owner) - } + result.key = { participant: metadata.owner } ev.emit('chats.upsert', [{ id: metadata.id, diff --git a/src/Types/GroupMetadata.ts b/src/Types/GroupMetadata.ts index baa5b96..276636f 100644 --- a/src/Types/GroupMetadata.ts +++ b/src/Types/GroupMetadata.ts @@ -6,7 +6,7 @@ export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' export interface GroupMetadata { id: string - owner: string + owner: string | undefined subject: string creation: number desc?: string