Fix Group setAddMembersAdminsOnly setMessagesAdminsOnly setInfoAdminsOnly (#3933)

* Add module to setGroupProperty

* Update methods setAddMembersAdminsOnly setMessagesAdmin setInfoAdminsOnlysOnly

---------

Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
This commit is contained in:
BenyFilho 2025-11-06 16:34:53 -03:00 • committed by GitHub
commit 05f651b521
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 10 deletions

View file

@ -297,12 +297,12 @@ class GroupChat extends Chat {
*/ */
async setAddMembersAdminsOnly(adminsOnly=true) { async setAddMembersAdminsOnly(adminsOnly=true) {
const success = await this.client.pupPage.evaluate(async (groupId, adminsOnly) => { const success = await this.client.pupPage.evaluate(async (groupId, adminsOnly) => {
const chatWid = window.Store.WidFactory.createWid(groupId); const chat = await window.WWebJS.getChat(groupId, { getAsModel: false });
try { try {
const response = await window.Store.GroupUtils.setGroupMemberAddMode(chatWid, 'member_add_mode', adminsOnly ? 0 : 1); await window.Store.GroupUtils.setGroupProperty(chat, 'member_add_mode', adminsOnly ? 0 : 1);
return response.name === 'SetMemberAddModeResponseSuccess'; return true;
} catch (err) { } catch (err) {
if(err.name === 'SmaxParsingFailure') return false; if(err.name === 'ServerStatusCodeError') return false;
throw err; throw err;
} }
}, this.id._serialized, adminsOnly); }, this.id._serialized, adminsOnly);
@ -318,9 +318,9 @@ class GroupChat extends Chat {
*/ */
async setMessagesAdminsOnly(adminsOnly=true) { async setMessagesAdminsOnly(adminsOnly=true) {
const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => { const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => {
const chatWid = window.Store.WidFactory.createWid(chatId); const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
try { try {
await window.Store.GroupUtils.setGroupProperty(chatWid, 'announcement', adminsOnly ? 1 : 0); await window.Store.GroupUtils.setGroupProperty(chat, 'announcement', adminsOnly ? 1 : 0);
return true; return true;
} catch (err) { } catch (err) {
if(err.name === 'ServerStatusCodeError') return false; if(err.name === 'ServerStatusCodeError') return false;
@ -341,9 +341,9 @@ class GroupChat extends Chat {
*/ */
async setInfoAdminsOnly(adminsOnly=true) { async setInfoAdminsOnly(adminsOnly=true) {
const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => { const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => {
const chatWid = window.Store.WidFactory.createWid(chatId); const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
try { try {
await window.Store.GroupUtils.setGroupProperty(chatWid, 'restrict', adminsOnly ? 1 : 0); await window.Store.GroupUtils.setGroupProperty(chat, 'restrict', adminsOnly ? 1 : 0);
return true; return true;
} catch (err) { } catch (err) {
if(err.name === 'ServerStatusCodeError') return false; if(err.name === 'ServerStatusCodeError') return false;
@ -356,7 +356,7 @@ class GroupChat extends Chat {
this.groupMetadata.restrict = adminsOnly; this.groupMetadata.restrict = adminsOnly;
return true; return true;
} }
/** /**
* Deletes the group's picture. * Deletes the group's picture.
* @returns {Promise<boolean>} Returns true if the picture was properly deleted. This can return false if the user does not have the necessary permissions. * @returns {Promise<boolean>} Returns true if the picture was properly deleted. This can return false if the user does not have the necessary permissions.

View file

@ -139,7 +139,8 @@ exports.ExposeStore = () => {
...window.require('WAWebGroupCreateJob'), ...window.require('WAWebGroupCreateJob'),
...window.require('WAWebGroupModifyInfoJob'), ...window.require('WAWebGroupModifyInfoJob'),
...window.require('WAWebExitGroupAction'), ...window.require('WAWebExitGroupAction'),
...window.require('WAWebContactProfilePicThumbBridge') ...window.require('WAWebContactProfilePicThumbBridge'),
...window.require('WAWebSetPropertyGroupAction')
}; };
window.Store.GroupParticipants = { window.Store.GroupParticipants = {
...window.require('WAWebModifyParticipantsGroupAction'), ...window.require('WAWebModifyParticipantsGroupAction'),