fix: search WhatsApp account subdirs for LID mapping files
When jidToE164() is called without opts.authDir (e.g., from extract.ts), the LID reverse mapping lookup fails because it only searches the top-level credentials directory, not the whatsapp/<accountId>/ subdirs where the mapping files are actually stored. This causes the reply-to-bot trigger in groups to fail when the bot's JID uses the WhatsApp LID format, as the implicit mention comparison can't resolve the LID to an E164 phone number. Fixes #2771
This commit is contained in:
parent
3f83afe4a6
commit
7a5732b098
23
src/utils.ts
23
src/utils.ts
@ -89,7 +89,28 @@ function resolveLidMappingDirs(opts?: JidToE164Options): string[] {
|
||||
addDir(opts?.authDir);
|
||||
for (const dir of opts?.lidMappingDirs ?? []) addDir(dir);
|
||||
addDir(resolveOAuthDir());
|
||||
addDir(path.join(CONFIG_DIR, "credentials"));
|
||||
const credentialsDir = path.join(CONFIG_DIR, "credentials");
|
||||
addDir(credentialsDir);
|
||||
|
||||
// Also search WhatsApp account subdirectories for LID mappings
|
||||
const waDir = path.join(credentialsDir, "whatsapp");
|
||||
try {
|
||||
if (fs.existsSync(waDir) && fs.statSync(waDir).isDirectory()) {
|
||||
for (const account of fs.readdirSync(waDir)) {
|
||||
const accountDir = path.join(waDir, account);
|
||||
try {
|
||||
if (fs.statSync(accountDir).isDirectory()) {
|
||||
dirs.add(accountDir);
|
||||
}
|
||||
} catch {
|
||||
// Skip if can't stat
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Skip if whatsapp dir doesn't exist or can't be read
|
||||
}
|
||||
|
||||
return [...dirs];
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user