diff --git a/README.md b/README.md index 64b6929..50578ff 100644 --- a/README.md +++ b/README.md @@ -606,6 +606,15 @@ WA uses an encrypted form of communication to send chat/app updates. This has be }, '123456@s.whatsapp.net') ``` + +- Star/unstar a message + ``` ts + await sock.chatModify({ + star: { + messages: [{ id: 'messageID', fromMe: true // or `false` }], + star: true // - true: Star Message; false: Unstar Message + }},'123456@s.whatsapp.net'); + ``` **Note:** if you mess up one of your updates, WA can log you out of all your devices and you'll have to log in again. diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index f38425f..286506d 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -777,6 +777,18 @@ export const makeChatsSocket = (config: SocketConfig) => { return appPatch(patch) } + /** + * Star or Unstar a message + */ + const star = (jid: string, messages: { id: string, fromMe?: boolean }[], star: boolean) => { + return chatModify({ + star: { + messages, + star + } + }, jid) + } + /** * Adds label for the chats */ @@ -999,6 +1011,7 @@ export const makeChatsSocket = (config: SocketConfig) => { addChatLabel, removeChatLabel, addMessageLabel, - removeMessageLabel + removeMessageLabel, + star } } diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index bdc00be..93a2fa8 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -398,7 +398,6 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { for(const { attrs } of blocklists) { const blocklist = [attrs.jid] const type = (attrs.action === 'block') ? 'add' : 'remove' - ev.emit('blocklist.update', { blocklist, type }) } } diff --git a/src/Utils/chat-utils.ts b/src/Utils/chat-utils.ts index b6668b8..22e4243 100644 --- a/src/Utils/chat-utils.ts +++ b/src/Utils/chat-utils.ts @@ -583,6 +583,19 @@ export const chatModificationToAppPatch = ( apiVersion: 5, operation: OP.SET } + } else if('star' in mod) { + const key = mod.star.messages[0] + patch = { + syncAction: { + starAction: { + starred: !!mod.star.star + } + }, + index: ['star', jid, key.id, key.fromMe ? '1' : '0', '0'], + type: 'regular_low', + apiVersion: 2, + operation: OP.SET + } } else if('delete' in mod) { patch = { syncAction: {