mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 20:58:26 +00:00
fix (telegram/whatsapp): use account-scoped pairing allowlists
This commit is contained in:
@@ -227,7 +227,11 @@ export const registerTelegramHandlers = ({
|
||||
}
|
||||
}
|
||||
|
||||
const storeAllowFrom = await readChannelAllowFromStore("telegram").catch(() => []);
|
||||
const storeAllowFrom = await readChannelAllowFromStore(
|
||||
"telegram",
|
||||
process.env,
|
||||
accountId,
|
||||
).catch(() => []);
|
||||
await processMessage(primaryEntry.ctx, allMedia, storeAllowFrom);
|
||||
} catch (err) {
|
||||
runtime.error?.(danger(`media group handler failed: ${String(err)}`));
|
||||
@@ -258,7 +262,11 @@ export const registerTelegramHandlers = ({
|
||||
date: last.msg.date ?? first.msg.date,
|
||||
};
|
||||
|
||||
const storeAllowFrom = await readChannelAllowFromStore("telegram").catch(() => []);
|
||||
const storeAllowFrom = await readChannelAllowFromStore(
|
||||
"telegram",
|
||||
process.env,
|
||||
accountId,
|
||||
).catch(() => []);
|
||||
const baseCtx = first.ctx;
|
||||
const getFile =
|
||||
typeof baseCtx.getFile === "function" ? baseCtx.getFile.bind(baseCtx) : async () => ({});
|
||||
@@ -330,6 +338,7 @@ export const registerTelegramHandlers = ({
|
||||
const isForum = callbackMessage.chat.is_forum === true;
|
||||
const groupAllowContext = await resolveTelegramGroupAllowFromContext({
|
||||
chatId,
|
||||
accountId,
|
||||
isForum,
|
||||
messageThreadId,
|
||||
groupAllowFrom,
|
||||
@@ -699,6 +708,7 @@ export const registerTelegramHandlers = ({
|
||||
const isForum = msg.chat.is_forum === true;
|
||||
const groupAllowContext = await resolveTelegramGroupAllowFromContext({
|
||||
chatId,
|
||||
accountId,
|
||||
isForum,
|
||||
messageThreadId,
|
||||
groupAllowFrom,
|
||||
|
||||
@@ -273,6 +273,7 @@ export const buildTelegramMessageContext = async ({
|
||||
const { code, created } = await upsertChannelPairingRequest({
|
||||
channel: "telegram",
|
||||
id: telegramUserId,
|
||||
accountId: account.accountId,
|
||||
meta: {
|
||||
username: from?.username,
|
||||
firstName: from?.first_name,
|
||||
|
||||
@@ -127,6 +127,7 @@ async function resolveTelegramCommandAuth(params: {
|
||||
msg: NonNullable<TelegramNativeCommandContext["message"]>;
|
||||
bot: Bot;
|
||||
cfg: OpenClawConfig;
|
||||
accountId: string;
|
||||
telegramCfg: TelegramAccountConfig;
|
||||
allowFrom?: Array<string | number>;
|
||||
groupAllowFrom?: Array<string | number>;
|
||||
@@ -142,6 +143,7 @@ async function resolveTelegramCommandAuth(params: {
|
||||
msg,
|
||||
bot,
|
||||
cfg,
|
||||
accountId,
|
||||
telegramCfg,
|
||||
allowFrom,
|
||||
groupAllowFrom,
|
||||
@@ -156,6 +158,7 @@ async function resolveTelegramCommandAuth(params: {
|
||||
const isForum = (msg.chat as { is_forum?: boolean }).is_forum === true;
|
||||
const groupAllowContext = await resolveTelegramGroupAllowFromContext({
|
||||
chatId,
|
||||
accountId,
|
||||
isForum,
|
||||
messageThreadId,
|
||||
groupAllowFrom,
|
||||
@@ -371,6 +374,7 @@ export const registerTelegramNativeCommands = ({
|
||||
msg,
|
||||
bot,
|
||||
cfg,
|
||||
accountId,
|
||||
telegramCfg,
|
||||
allowFrom,
|
||||
groupAllowFrom,
|
||||
@@ -623,6 +627,7 @@ export const registerTelegramNativeCommands = ({
|
||||
msg,
|
||||
bot,
|
||||
cfg,
|
||||
accountId,
|
||||
telegramCfg,
|
||||
allowFrom,
|
||||
groupAllowFrom,
|
||||
|
||||
@@ -18,6 +18,7 @@ export type TelegramThreadSpec = {
|
||||
|
||||
export async function resolveTelegramGroupAllowFromContext(params: {
|
||||
chatId: string | number;
|
||||
accountId?: string;
|
||||
isForum?: boolean;
|
||||
messageThreadId?: number | null;
|
||||
groupAllowFrom?: Array<string | number>;
|
||||
@@ -38,7 +39,11 @@ export async function resolveTelegramGroupAllowFromContext(params: {
|
||||
isForum: params.isForum,
|
||||
messageThreadId: params.messageThreadId,
|
||||
});
|
||||
const storeAllowFrom = await readChannelAllowFromStore("telegram").catch(() => []);
|
||||
const storeAllowFrom = await readChannelAllowFromStore(
|
||||
"telegram",
|
||||
process.env,
|
||||
params.accountId,
|
||||
).catch(() => []);
|
||||
const { groupConfig, topicConfig } = params.resolveTelegramGroupConfig(
|
||||
params.chatId,
|
||||
resolvedThreadId,
|
||||
|
||||
Reference in New Issue
Block a user