Skip to content

Commit

Permalink
Merge pull req
Browse files Browse the repository at this point in the history
Add support for star/unstar messages (WhiskeySockets#539)
  • Loading branch information
iamrony777 committed Dec 16, 2023
1 parent 95eb087 commit 2941bb2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Socket/chats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -999,6 +1011,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
addChatLabel,
removeChatLabel,
addMessageLabel,
removeMessageLabel
removeMessageLabel,
star
}
}
13 changes: 13 additions & 0 deletions src/Utils/chat-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 2941bb2

Please sign in to comment.