diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index 303f3f6f320..ca14f0e81e5 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/Utils/chat-utils.ts b/src/Utils/chat-utils.ts index 5692e517794..38b814d505e 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: {