docs: add some comments for "chatModify" + logging for app patch

This commit is contained in:
Adhiraj Singh
2021-11-29 23:57:30 +05:30
parent 0d27fc467b
commit a8decb9c11

View File

@@ -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<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>[]) => {
const patch = chatModificationToAppPatch(mod, jid, lastMessages)
return appPatch(patch)