docs: logging + more docs

This commit is contained in:
Adhiraj Singh
2022-04-06 20:41:07 +05:30
parent e6e8e24ea9
commit feb32465ca

View File

@@ -24,12 +24,13 @@ export const makeChatsSocket = (config: SocketConfig) => {
} = sock
const mutationMutex = makeMutex()
/// helper function to fetch an app state sync key
/** helper function to fetch the given app state sync key */
const getAppStateSyncKey = async(keyId: string) => {
const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId])
return key
}
/** helper function to run a generic IQ query */
const interactiveQuery = async(userNodes: BinaryNode[], queryNode: BinaryNode) => {
const result = await query({
tag: 'iq',
@@ -109,6 +110,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
}
}
/** update the profile picture for yourself or a group */
const updateProfilePicture = async(jid: string, content: WAMediaUpload) => {
const { img } = await generateProfilePicture(content)
await query({
@@ -296,7 +298,10 @@ export const makeChatsSocket = (config: SocketConfig) => {
const { state: newState, mutations } = await decodeSyncdSnapshot(name, snapshot, getAppStateSyncKey, initialVersionMap[name])
states[name] = newState
logger.info(`restored state of ${name} from snapshot to v${newState.version} with ${mutations.length} mutations`)
logger.info(
{ mutations: logger.level === 'trace' ? mutations : undefined },
`restored state of ${name} from snapshot to v${newState.version} with ${mutations.length} mutations`
)
await authState.keys.set({ 'app-state-sync-version': { [name]: newState } })