Skip to content

Commit

Permalink
feat: Added getAllBroadcastList function (close #184)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed May 7, 2021
1 parent 7f1348a commit 351be03
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/api/layers/retriever.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ export class RetrieverLayer extends SenderLayer {
}
}

/**
* Retrieve all broadcast list
* @category Group
* @returns array of broadcast list
*/
public async getAllBroadcastList() {
const chats = await this.page.evaluate(() => WAPI.getAllChats());
return chats.filter(
(chat) => chat.isBroadcast && chat.id._serialized !== 'status@broadcast'
);
}

/**
* Retrieves contact detail object of given contact id
* @category Contact
Expand Down
4 changes: 3 additions & 1 deletion src/api/model/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ export interface Chat {
t: number;
unreadCount: number;
archive: boolean;
isReadOnly: boolean;
muteExpiration: number;
name: string;
notSpam: boolean;
pin: number;
msgs: null;
kind: string;
isBroadcast: boolean;
isGroup: boolean;
isReadOnly: boolean;
isUser: boolean;
contact: Contact;
groupMetadata: GroupMetadata;
presence: Presence;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/wapi/serializers/serialize-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export const _serializeChatObj = (obj) => {
}
return Object.assign(window.WAPI._serializeRawObj(obj), {
kind: obj.kind,
isBroadcast: obj.isBroadcast,
isGroup: obj.isGroup,
isUser: obj.isUser,
contact: obj['contact']
? window.WAPI._serializeContactObj(obj['contact'])
: null,
Expand Down

0 comments on commit 351be03

Please sign in to comment.