Merge pull request #539 from azudindaem/patch-1

Fix: support Star or Unstar message
This commit is contained in:
Rajeh Taher
2024-01-01 01:03:48 +02:00
committed by GitHub
4 changed files with 36 additions and 2 deletions

View File

@@ -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.

View File

@@ -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
}
}

View File

@@ -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 })
}
}

View File

@@ -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: {