mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
docs: logging + more docs
This commit is contained in:
@@ -24,12 +24,13 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
|||||||
} = sock
|
} = sock
|
||||||
|
|
||||||
const mutationMutex = makeMutex()
|
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 getAppStateSyncKey = async(keyId: string) => {
|
||||||
const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId])
|
const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId])
|
||||||
return key
|
return key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** helper function to run a generic IQ query */
|
||||||
const interactiveQuery = async(userNodes: BinaryNode[], queryNode: BinaryNode) => {
|
const interactiveQuery = async(userNodes: BinaryNode[], queryNode: BinaryNode) => {
|
||||||
const result = await query({
|
const result = await query({
|
||||||
tag: 'iq',
|
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 updateProfilePicture = async(jid: string, content: WAMediaUpload) => {
|
||||||
const { img } = await generateProfilePicture(content)
|
const { img } = await generateProfilePicture(content)
|
||||||
await query({
|
await query({
|
||||||
@@ -296,7 +298,10 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
|||||||
const { state: newState, mutations } = await decodeSyncdSnapshot(name, snapshot, getAppStateSyncKey, initialVersionMap[name])
|
const { state: newState, mutations } = await decodeSyncdSnapshot(name, snapshot, getAppStateSyncKey, initialVersionMap[name])
|
||||||
states[name] = newState
|
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 } })
|
await authState.keys.set({ 'app-state-sync-version': { [name]: newState } })
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user