mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: logout error when not logged in
This commit is contained in:
@@ -345,24 +345,28 @@ export const makeSocket = ({
|
|||||||
)
|
)
|
||||||
/** logout & invalidate connection */
|
/** logout & invalidate connection */
|
||||||
const logout = async() => {
|
const logout = async() => {
|
||||||
await sendNode({
|
const jid = authState.creds.me?.id
|
||||||
tag: 'iq',
|
if(jid) {
|
||||||
attrs: {
|
await sendNode({
|
||||||
to: S_WHATSAPP_NET,
|
tag: 'iq',
|
||||||
type: 'set',
|
attrs: {
|
||||||
id: generateMessageTag(),
|
to: S_WHATSAPP_NET,
|
||||||
xmlns: 'md'
|
type: 'set',
|
||||||
},
|
id: generateMessageTag(),
|
||||||
content: [
|
xmlns: 'md'
|
||||||
{
|
},
|
||||||
tag: 'remove-companion-device',
|
content: [
|
||||||
attrs: {
|
{
|
||||||
jid: authState.creds.me!.id,
|
tag: 'remove-companion-device',
|
||||||
reason: 'user_initiated'
|
attrs: {
|
||||||
|
jid: jid,
|
||||||
|
reason: 'user_initiated'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
end(new Boom('Intentional Logout', { statusCode: DisconnectReason.loggedOut }))
|
end(new Boom('Intentional Logout', { statusCode: DisconnectReason.loggedOut }))
|
||||||
}
|
}
|
||||||
/** Waits for the connection to WA to reach a state */
|
/** Waits for the connection to WA to reach a state */
|
||||||
|
|||||||
Reference in New Issue
Block a user