diff --git a/src/group/functions/addParticipants.ts b/src/group/functions/addParticipants.ts index b64ba6d4ab..cae0e34056 100644 --- a/src/group/functions/addParticipants.ts +++ b/src/group/functions/addParticipants.ts @@ -34,6 +34,7 @@ const messageCodes: { 200: 'OK', 403: "Can't join this group because the number was restricted it.", 409: "Can't join this group because the number is already a member of it.", + 421: 'Member not added, awaiting approval!', }; /** diff --git a/src/group/functions/ensureGroup.ts b/src/group/functions/ensureGroup.ts index 0bd5009025..44184a83f4 100644 --- a/src/group/functions/ensureGroup.ts +++ b/src/group/functions/ensureGroup.ts @@ -1,5 +1,5 @@ /*! - * Copyright 2021 WPPConnect Team + * Copyright 2024 WPPConnect Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,9 +29,13 @@ export async function ensureGroup(groupId: string | Wid, checkIsAdmin = false) { ); } - await GroupMetadataStore.find(groupChat.id); + const datagroup = await GroupMetadataStore.find(groupChat.id); - if (checkIsAdmin && !(await iAmAdmin(groupId))) { + if ( + checkIsAdmin && + !(await iAmAdmin(groupId)) && + datagroup.memberAddMode !== 'all_member_add' + ) { throw new WPPError( 'group_you_are_not_admin', `You are not admin in ${groupChat.id._serialized}` diff --git a/src/whatsapp/models/GroupMetadataModel.ts b/src/whatsapp/models/GroupMetadataModel.ts index 46b29c8bc6..c785d20680 100644 --- a/src/whatsapp/models/GroupMetadataModel.ts +++ b/src/whatsapp/models/GroupMetadataModel.ts @@ -1,5 +1,5 @@ /*! - * Copyright 2021 WPPConnect Team + * Copyright 2024 WPPConnect Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ interface Props { id: Wid; creation?: any; owner?: any; + memberAddMode?: string; subject?: string; subjectTime?: any; desc?: string;