fix: Client.createGroup + GroupChat.addParticipants (#3670)

* Adjustment addParticipants

* createGroup fully refactored, fixed bugs, added creation options and updated docs

* fix: eslint fix

* refactor: GroupChat.addParticipants fully refactored

* fix: eslint fix

---------

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
This commit is contained in:
BenyFilho 2025-08-01 00:43:45 -03:00 • committed by GitHub
commit 81fd090e36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -871,8 +871,8 @@ exports.LoadUtils = () => {
return dataUrl;
return Object.assign(media, {
mimetype: options.mimeType,
data: dataUrl.replace(`data:${options.mimeType};base64,`, '')
mimetype: options.mimetype,
data: dataUrl.replace(`data:${options.mimetype};base64,`, '')
});
};
@ -941,30 +941,14 @@ exports.LoadUtils = () => {
return undefined;
};
window.WWebJS.getAddParticipantsRpcResult = async (groupMetadata, groupWid, participantWid) => {
const participantLidArgs = groupMetadata?.isLidAddressingMode
? {
phoneNumber: participantWid,
lid: window.Store.LidUtils.getCurrentLid(participantWid)
}
: { phoneNumber: participantWid };
window.WWebJS.getAddParticipantsRpcResult = async (groupWid, participantWid) => {
const iqTo = window.Store.WidToJid.widToGroupJid(groupWid);
const participantArgs =
participantLidArgs.lid
? [{
participantJid: window.Store.WidToJid.widToUserJid(participantLidArgs.lid),
phoneNumberMixinArgs: {
anyPhoneNumber: window.Store.WidToJid.widToUserJid(participantLidArgs.phoneNumber)
}
}]
: [{
participantJid: window.Store.WidToJid.widToUserJid(participantLidArgs.phoneNumber)
}];
const participantArgs = [{
participantJid: window.Store.WidToJid.widToUserJid(participantWid)
}];
let rpcResult, resultArgs;
const isOldImpl = window.compareWwebVersions(window.Debug.VERSION, '<=', '2.2335.9');
const data = {
name: undefined,
code: undefined,
@ -974,12 +958,10 @@ exports.LoadUtils = () => {
try {
rpcResult = await window.Store.GroupParticipants.sendAddParticipantsRPC({ participantArgs, iqTo });
resultArgs = isOldImpl
? rpcResult.value.addParticipant[0].addParticipantsParticipantMixins
: rpcResult.value.addParticipant[0]
.addParticipantsParticipantAddedOrNonRegisteredWaUserParticipantErrorLidResponseMixinGroup
.value
.addParticipantsParticipantMixins;
resultArgs = rpcResult.value.addParticipant[0]
.addParticipantsParticipantAddedOrNonRegisteredWaUserParticipantErrorLidResponseMixinGroup
.value
.addParticipantsParticipantMixins;
} catch (err) {
data.code = 400;
return data;