feat: implement pin chat modification

This commit is contained in:
Adhiraj Singh
2021-11-25 13:36:29 +05:30
parent 032b2a314b
commit ddf6daba65
2 changed files with 15 additions and 0 deletions

View File

@@ -382,9 +382,12 @@ export const makeChatsSocket = (config: SocketConfig) => {
name: action?.pushNameSetting?.name!
}
ev.emit('creds.update', { me })
} else if(action?.pinAction) {
update.pin = action.pinAction?.pinned ? toNumber(action.timestamp) : undefined
} else {
logger.warn({ action, id }, 'unprocessable update')
}
if(Object.keys(update).length > 1) {
updates[update.id] = {
...(updates[update.id] || {}),

View File

@@ -481,6 +481,18 @@ export const chatModificationToAppPatch = (
operation: OP.SET
}
}
} else if('pin' in mod) {
patch = {
syncAction: {
pinAction: {
pinned: !!mod.pin
}
},
index: ['pin_v1', '919646328797@s.whatsapp.net'],
type: 'regular_low',
apiVersion: 5,
operation: mod.pin ? OP.SET : OP.REMOVE
}
} else {
throw new Boom('not supported')
}