Skip to content

Commit

Permalink
fix: Fixed group functions for WhatsApp >= 2.2301.5
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jan 10, 2023
1 parent dee775a commit 69e5db5
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/whatsapp/functions/index.ts
Expand Up @@ -44,6 +44,7 @@ export * from './isAnimatedWebp';
export * from './isAuthenticated';
export * from './isRegistered';
export * from './isUnreadTypeMsg';
export * from './joinGroupViaInvite';
export * from './markSeen';
export * from './mediaTypeFromProtobuf';
export * from './msgFindQuery';
Expand All @@ -53,6 +54,7 @@ export * from './productVisibilitySet';
export * from './profilePic';
export * from './randomHex';
export * from './randomId';
export * from './resetGroupInviteCode';
export * from './sendCallSignalingMsg';
export * from './sendClear';
export * from './sendCreateGroup';
Expand Down
31 changes: 31 additions & 0 deletions src/whatsapp/functions/joinGroupViaInvite.ts
@@ -0,0 +1,31 @@
/*!
* Copyright 2021 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Wid } from '..';
import { exportModule } from '../exportModule';

/**
* @whatsapp 153438 >= 2.2301.5
*/
export declare function joinGroupViaInvite(groupId: Wid): Promise<{ gid: Wid }>;

exportModule(
exports,
{
joinGroupViaInvite: 'joinGroupViaInvite',
},
(m) => m.joinGroupViaInvite
);
33 changes: 33 additions & 0 deletions src/whatsapp/functions/resetGroupInviteCode.ts
@@ -0,0 +1,33 @@
/*!
* Copyright 2021 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Wid } from '..';
import { exportModule } from '../exportModule';

/**
* @whatsapp 153438 >= 2.2301.5
*/
export declare function resetGroupInviteCode(
groupId: Wid
): Promise<{ code: string }>;

exportModule(
exports,
{
resetGroupInviteCode: 'resetGroupInviteCode',
},
(m) => m.resetGroupInviteCode
);
29 changes: 21 additions & 8 deletions src/whatsapp/functions/sendGroupParticipants.ts
Expand Up @@ -70,14 +70,27 @@ export declare function sendDemoteParticipants(
exportModule(
exports,
{
sendAddParticipants: 'sendAddParticipants',
sendRemoveParticipants: 'sendRemoveParticipants',
sendPromoteParticipants: 'sendPromoteParticipants',
sendDemoteParticipants: 'sendDemoteParticipants',
sendAddParticipants: ['sendAddParticipants', 'addGroupParticipants'],
sendRemoveParticipants: [
'sendRemoveParticipants',
'removeGroupParticipants',
],
sendPromoteParticipants: [
'sendPromoteParticipants',
'promoteGroupParticipants',
],
sendDemoteParticipants: [
'sendDemoteParticipants',
'demoteGroupParticipants',
],
},
(m) =>
m.sendAddParticipants &&
m.sendRemoveParticipants &&
m.sendPromoteParticipants &&
m.sendDemoteParticipants
(m.sendAddParticipants &&
m.sendRemoveParticipants &&
m.sendPromoteParticipants &&
m.sendDemoteParticipants) || // @whatsapp < 2.2301.5
(m.addGroupParticipants &&
m.removeGroupParticipants &&
m.promoteGroupParticipants &&
m.demoteGroupParticipants) // @whatsapp >= 2.2301.5
);
8 changes: 8 additions & 0 deletions src/whatsapp/functions/sendJoinGroupViaInvite.ts
Expand Up @@ -14,8 +14,10 @@
* limitations under the License.
*/

import * as webpack from '../../webpack';
import { Wid } from '..';
import { exportModule } from '../exportModule';
import { joinGroupViaInvite } from './joinGroupViaInvite';

/** @whatsapp 69586
* @whatsapp 769586 >= 2.2222.8
Expand All @@ -29,3 +31,9 @@ exportModule(
},
(m) => m.sendJoinGroupViaInvite
);

webpack.injectFallbackModule('sendJoinGroupViaInvite', {
sendJoinGroupViaInvite: async (groupId: Wid) => {
return await joinGroupViaInvite(groupId).then((value) => value.gid);
},
});
8 changes: 8 additions & 0 deletions src/whatsapp/functions/sendRevokeGroupInviteCode.ts
Expand Up @@ -14,8 +14,10 @@
* limitations under the License.
*/

import * as webpack from '../../webpack';
import { Wid } from '..';
import { exportModule } from '../exportModule';
import { resetGroupInviteCode } from './resetGroupInviteCode';

/** @whatsapp 69586
* @whatsapp 769586 >= 2.2222.8
Expand All @@ -31,3 +33,9 @@ exportModule(
},
(m) => m.sendRevokeGroupInviteCode
);

webpack.injectFallbackModule('sendRevokeGroupInviteCode', {
sendRevokeGroupInviteCode: async (groupId: Wid) => {
return await resetGroupInviteCode(groupId).then((value) => value.code);
},
});
11 changes: 7 additions & 4 deletions src/whatsapp/functions/setGroup.ts
Expand Up @@ -48,10 +48,13 @@ export declare function sendSetGroupProperty(
exportModule(
exports,
{
sendSetGroupSubject: 'sendSetGroupSubject',
sendSetGroupDescription: 'sendSetGroupDescription',
sendSetGroupProperty: 'sendSetGroupProperty',
sendSetGroupSubject: ['sendSetGroupSubject', 'setGroupSubject'],
sendSetGroupDescription: ['sendSetGroupDescription', 'setGroupDescription'],
sendSetGroupProperty: ['sendSetGroupProperty', 'setGroupProperty'],
},
(m) =>
m.sendSetGroupSubject && m.sendSetGroupDescription && m.sendSetGroupProperty
(m.sendSetGroupSubject &&
m.sendSetGroupDescription &&
m.sendSetGroupProperty) || // @whatsapp < 2.2301.5
(m.setGroupSubject && m.setGroupDescription && m.setGroupProperty) // @whatsapp >= 2.2301.5
);

0 comments on commit 69e5db5

Please sign in to comment.