style: format web inbound
This commit is contained in:
@@ -307,27 +307,27 @@ export async function monitorWebInbox(options: {
|
|||||||
const handleConnectionUpdate = (
|
const handleConnectionUpdate = (
|
||||||
update: Partial<import("@whiskeysockets/baileys").ConnectionState>,
|
update: Partial<import("@whiskeysockets/baileys").ConnectionState>,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
if (update.connection === "close") {
|
if (update.connection === "close") {
|
||||||
const status = getStatusCode(update.lastDisconnect?.error);
|
const status = getStatusCode(update.lastDisconnect?.error);
|
||||||
onCloseResolve?.({
|
|
||||||
status,
|
|
||||||
isLoggedOut: status === DisconnectReason.loggedOut,
|
|
||||||
error: update.lastDisconnect?.error,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
inboundLogger.error(
|
|
||||||
{ error: String(err) },
|
|
||||||
"connection.update handler error",
|
|
||||||
);
|
|
||||||
onCloseResolve?.({
|
onCloseResolve?.({
|
||||||
status: undefined,
|
status,
|
||||||
isLoggedOut: false,
|
isLoggedOut: status === DisconnectReason.loggedOut,
|
||||||
error: err,
|
error: update.lastDisconnect?.error,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
} catch (err) {
|
||||||
|
inboundLogger.error(
|
||||||
|
{ error: String(err) },
|
||||||
|
"connection.update handler error",
|
||||||
|
);
|
||||||
|
onCloseResolve?.({
|
||||||
|
status: undefined,
|
||||||
|
isLoggedOut: false,
|
||||||
|
error: err,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
sock.ev.on("connection.update", handleConnectionUpdate);
|
sock.ev.on("connection.update", handleConnectionUpdate);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -338,10 +338,7 @@ export async function monitorWebInbox(options: {
|
|||||||
sock.ev.off("connection.update", handleConnectionUpdate);
|
sock.ev.off("connection.update", handleConnectionUpdate);
|
||||||
} else {
|
} else {
|
||||||
sock.ev.removeListener?.("messages.upsert", handleMessagesUpsert);
|
sock.ev.removeListener?.("messages.upsert", handleMessagesUpsert);
|
||||||
sock.ev.removeListener?.(
|
sock.ev.removeListener?.("connection.update", handleConnectionUpdate);
|
||||||
"connection.update",
|
|
||||||
handleConnectionUpdate,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
sock.ws?.close();
|
sock.ws?.close();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user