mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Merge pull request #539 from azudindaem/patch-1
Fix: support Star or Unstar message
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user