mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 21:48:27 +00:00
fix(cron/whatsapp): route implicit delivery to allowlisted recipients (openclaw#21533) thanks @Takhoffman
Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -269,6 +269,16 @@ async function readAllowFromStateForPath(
|
||||
return normalizeAllowFromList(channel, value);
|
||||
}
|
||||
|
||||
function readAllowFromStateForPathSync(channel: PairingChannel, filePath: string): string[] {
|
||||
try {
|
||||
const raw = fs.readFileSync(filePath, "utf8");
|
||||
const parsed = JSON.parse(raw) as AllowFromStore;
|
||||
return normalizeAllowFromList(channel, parsed);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function readAllowFromState(params: {
|
||||
channel: PairingChannel;
|
||||
entry: string | number;
|
||||
@@ -341,6 +351,24 @@ export async function readChannelAllowFromStore(
|
||||
return dedupePreserveOrder([...scopedEntries, ...legacyEntries]);
|
||||
}
|
||||
|
||||
export function readChannelAllowFromStoreSync(
|
||||
channel: PairingChannel,
|
||||
env: NodeJS.ProcessEnv = process.env,
|
||||
accountId?: string,
|
||||
): string[] {
|
||||
const normalizedAccountId = accountId?.trim().toLowerCase() ?? "";
|
||||
if (!normalizedAccountId) {
|
||||
const filePath = resolveAllowFromPath(channel, env);
|
||||
return readAllowFromStateForPathSync(channel, filePath);
|
||||
}
|
||||
|
||||
const scopedPath = resolveAllowFromPath(channel, env, accountId);
|
||||
const scopedEntries = readAllowFromStateForPathSync(channel, scopedPath);
|
||||
const legacyPath = resolveAllowFromPath(channel, env);
|
||||
const legacyEntries = readAllowFromStateForPathSync(channel, legacyPath);
|
||||
return dedupePreserveOrder([...scopedEntries, ...legacyEntries]);
|
||||
}
|
||||
|
||||
type AllowFromStoreEntryUpdateParams = {
|
||||
channel: PairingChannel;
|
||||
entry: string | number;
|
||||
|
||||
Reference in New Issue
Block a user