mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-27 09:21:35 +07:00
fix(whatsapp): use async fs.promises.readFile for selfLid creds read
This commit is contained in:
committed by
Peter Steinberger
parent
770a5ee5b1
commit
f3fe019e3d
@@ -82,10 +82,11 @@ export async function monitorWebInbox(options: {
|
||||
// Bot's own LID (Linked Identity) — needed for reply-to-bot detection
|
||||
// when contextInfo.participant returns a LID instead of a phone JID.
|
||||
// Baileys 7 rc9 does not expose lid on sock.user, so read from creds file.
|
||||
const selfLid = (() => {
|
||||
const selfLid = await (async () => {
|
||||
try {
|
||||
const credsPath = path.join(options.authDir ?? "", "creds.json");
|
||||
const creds = JSON.parse(fs.readFileSync(credsPath, "utf-8"));
|
||||
const credsPath = path.join(options.authDir, "creds.json");
|
||||
const raw = await fs.promises.readFile(credsPath, "utf-8");
|
||||
const creds = JSON.parse(raw) as { me?: { lid?: string } };
|
||||
return creds?.me?.lid ?? undefined;
|
||||
} catch {
|
||||
return (sock.user as { lid?: string } | undefined)?.lid ?? undefined;
|
||||
|
||||
Reference in New Issue
Block a user