From a8decb9c1160ca73970986a0636aaf345e4bd67d Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Mon, 29 Nov 2021 23:57:30 +0530 Subject: [PATCH] docs: add some comments for "chatModify" + logging for app patch --- src/Socket/chats.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index 295cfcc..90e413e 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -412,6 +412,8 @@ export const makeChatsSocket = (config: SocketConfig) => { const name = patchCreate.type await mutationMutex.mutex( async() => { + logger.debug({ patch: patchCreate }, 'applying app patch') + await resyncAppState([name]) const initial = await authState.keys.getAppStateSyncVersion(name) const { patch, state } = await encodeSyncdPatch( @@ -463,7 +465,11 @@ export const makeChatsSocket = (config: SocketConfig) => { } ) } - + /** + * modify a chat -- mark unread, read etc. + * lastMessages must be sorted in reverse chronologically + * requires the last messages till the last message received; required for archive & unread + */ const chatModify = (mod: ChatModification, jid: string, lastMessages: Pick[]) => { const patch = chatModificationToAppPatch(mod, jid, lastMessages) return appPatch(patch)