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:
parent
4327a5f681
commit
05f651b521
2 changed files with 11 additions and 10 deletions
|
|
@ -297,12 +297,12 @@ class GroupChat extends Chat {
|
|||
*/
|
||||
async setAddMembersAdminsOnly(adminsOnly=true) {
|
||||
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 {
|
||||
const response = await window.Store.GroupUtils.setGroupMemberAddMode(chatWid, 'member_add_mode', adminsOnly ? 0 : 1);
|
||||
return response.name === 'SetMemberAddModeResponseSuccess';
|
||||
await window.Store.GroupUtils.setGroupProperty(chat, 'member_add_mode', adminsOnly ? 0 : 1);
|
||||
return true;
|
||||
} catch (err) {
|
||||
if(err.name === 'SmaxParsingFailure') return false;
|
||||
if(err.name === 'ServerStatusCodeError') return false;
|
||||
throw err;
|
||||
}
|
||||
}, this.id._serialized, adminsOnly);
|
||||
|
|
@ -318,9 +318,9 @@ class GroupChat extends Chat {
|
|||
*/
|
||||
async setMessagesAdminsOnly(adminsOnly=true) {
|
||||
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 {
|
||||
await window.Store.GroupUtils.setGroupProperty(chatWid, 'announcement', adminsOnly ? 1 : 0);
|
||||
await window.Store.GroupUtils.setGroupProperty(chat, 'announcement', adminsOnly ? 1 : 0);
|
||||
return true;
|
||||
} catch (err) {
|
||||
if(err.name === 'ServerStatusCodeError') return false;
|
||||
|
|
@ -341,9 +341,9 @@ class GroupChat extends Chat {
|
|||
*/
|
||||
async setInfoAdminsOnly(adminsOnly=true) {
|
||||
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 {
|
||||
await window.Store.GroupUtils.setGroupProperty(chatWid, 'restrict', adminsOnly ? 1 : 0);
|
||||
await window.Store.GroupUtils.setGroupProperty(chat, 'restrict', adminsOnly ? 1 : 0);
|
||||
return true;
|
||||
} catch (err) {
|
||||
if(err.name === 'ServerStatusCodeError') return false;
|
||||
|
|
|
|||
|
|
@ -139,7 +139,8 @@ exports.ExposeStore = () => {
|
|||
...window.require('WAWebGroupCreateJob'),
|
||||
...window.require('WAWebGroupModifyInfoJob'),
|
||||
...window.require('WAWebExitGroupAction'),
|
||||
...window.require('WAWebContactProfilePicThumbBridge')
|
||||
...window.require('WAWebContactProfilePicThumbBridge'),
|
||||
...window.require('WAWebSetPropertyGroupAction')
|
||||
};
|
||||
window.Store.GroupParticipants = {
|
||||
...window.require('WAWebModifyParticipantsGroupAction'),
|
||||
|
|
|
|||
Loading…
Reference in a new issue