Skip to content

Commit

Permalink
feat: new function to change group permission
Browse files Browse the repository at this point in the history
  • Loading branch information
joaosouz4dev committed Nov 6, 2020
1 parent 9166c68 commit 9f4eeef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/api/layers/controls.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ declare module WAPI {
const markUnseenMessage: (messageId: string) => boolean;
const blockContact: (messageId: string) => boolean;
const unblockContact: (messageId: string) => boolean;
const setMessagesAdminsOnly: (chatId: string, option: boolean) => boolean;
}

export class ControlsLayer extends UILayer {
Expand Down Expand Up @@ -189,4 +190,17 @@ export class ControlsLayer extends UILayer {
{ contactId: chatId, messageId, onlyLocal }
);
}

/**
* Archive and unarchive chat messages with true or false
* @param chatId {string} id '[email protected]'
* @param option {boolean} true or false
* @returns boolean
*/
public async setMessagesAdminsOnly(chatId: string, option: boolean) {
return this.page.evaluate(
({ chatId, option }) => WAPI.setMessagesAdminsOnly(chatId, option),
{ chatId, option }
);
}
}
5 changes: 3 additions & 2 deletions src/lib/wapi/functions/send-sticker.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ export async function sendSticker(sticker, chatId, metadata, type) {
);
result = result.join('');
var m = { type: type },
obj,
To = await WAPI.getchatId(chatId);
if (result === 'OK') {
var obj = WAPI.scope(To, false, result, null);
obj = WAPI.scope(To, false, result, null);
Object.assign(obj, m);
return obj;
} else {
var obj = WAPI.scope(To, true, result, null);
obj = WAPI.scope(To, true, result, null);
Object.assign(obj, m);
return obj;
}
Expand Down
5 changes: 5 additions & 0 deletions src/lib/wapi/wapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,8 @@ window.WAPI.onIncomingCall = function (callback) {
window.Store.Call.on('add', callback);
return true;
};

window.WAPI.setMessagesAdminsOnly = async function (chatId, option) {
await Store.WapQuery.setGroupProperty(chatId, 'announcement', option);
return true;
};

1 comment on commit 9f4eeef

@joaosouz4dev
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.