mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 13:44:32 +00:00
Harden Telegram poll gating and schema consistency (#36547)
Merged via squash.
Prepared head SHA: f77824419e
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
committed by
GitHub
parent
f771ba8de9
commit
6dfd39c32f
@@ -4,6 +4,7 @@ import { withEnv } from "../test-utils/env.js";
|
||||
import {
|
||||
listTelegramAccountIds,
|
||||
resetMissingDefaultWarnFlag,
|
||||
resolveTelegramPollActionGateState,
|
||||
resolveDefaultTelegramAccountId,
|
||||
resolveTelegramAccount,
|
||||
} from "./accounts.js";
|
||||
@@ -308,6 +309,26 @@ describe("resolveTelegramAccount allowFrom precedence", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveTelegramPollActionGateState", () => {
|
||||
it("requires both sendMessage and poll actions", () => {
|
||||
const state = resolveTelegramPollActionGateState((key) => key !== "poll");
|
||||
expect(state).toEqual({
|
||||
sendMessageEnabled: true,
|
||||
pollEnabled: false,
|
||||
enabled: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("returns enabled only when both actions are enabled", () => {
|
||||
const state = resolveTelegramPollActionGateState(() => true);
|
||||
expect(state).toEqual({
|
||||
sendMessageEnabled: true,
|
||||
pollEnabled: true,
|
||||
enabled: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveTelegramAccount groups inheritance (#30673)", () => {
|
||||
const createMultiAccountGroupsConfig = (): OpenClawConfig => ({
|
||||
channels: {
|
||||
|
||||
@@ -142,6 +142,24 @@ export function createTelegramActionGate(params: {
|
||||
});
|
||||
}
|
||||
|
||||
export type TelegramPollActionGateState = {
|
||||
sendMessageEnabled: boolean;
|
||||
pollEnabled: boolean;
|
||||
enabled: boolean;
|
||||
};
|
||||
|
||||
export function resolveTelegramPollActionGateState(
|
||||
isActionEnabled: (key: keyof TelegramActionConfig, defaultValue?: boolean) => boolean,
|
||||
): TelegramPollActionGateState {
|
||||
const sendMessageEnabled = isActionEnabled("sendMessage");
|
||||
const pollEnabled = isActionEnabled("poll");
|
||||
return {
|
||||
sendMessageEnabled,
|
||||
pollEnabled,
|
||||
enabled: sendMessageEnabled && pollEnabled,
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveTelegramAccount(params: {
|
||||
cfg: OpenClawConfig;
|
||||
accountId?: string | null;
|
||||
|
||||
Reference in New Issue
Block a user