fix(doctor): add telegram first-run guidance

This commit is contained in:
Vincent Koc
2026-03-21 08:23:42 -07:00
parent 7918308b1a
commit 2ead75ea0e
2 changed files with 32 additions and 4 deletions

View File

@@ -109,7 +109,7 @@ describe("doctor config flow", () => {
).toBe(false);
});
it("does not warn for fresh Telegram baseline without configured groups", async () => {
it("shows first-time Telegram guidance without the old groupAllowFrom warning", async () => {
const doctorWarnings = await collectDoctorWarnings({
channels: {
telegram: {
@@ -126,9 +126,17 @@ describe("doctor config flow", () => {
line.includes("groupAllowFrom"),
),
).toBe(false);
expect(
doctorWarnings.some(
(line) =>
line.includes("channels.telegram: Telegram is in first-time setup mode.") &&
line.includes("DMs use pairing mode") &&
line.includes("channels.telegram.groups"),
),
).toBe(true);
});
it("does not warn for account-scoped Telegram baseline without configured groups", async () => {
it("shows account-scoped first-time Telegram guidance without the old groupAllowFrom warning", async () => {
const doctorWarnings = await collectDoctorWarnings({
channels: {
telegram: {
@@ -149,6 +157,16 @@ describe("doctor config flow", () => {
line.includes("groupAllowFrom"),
),
).toBe(false);
expect(
doctorWarnings.some(
(line) =>
line.includes(
"channels.telegram.accounts.default: Telegram is in first-time setup mode.",
) &&
line.includes("DMs use pairing mode") &&
line.includes("channels.telegram.accounts.default.groups"),
),
).toBe(true);
});
it("warns on mutable Zalouser group entries when dangerous name matching is disabled", async () => {

View File

@@ -1383,8 +1383,18 @@ function detectEmptyAllowlistPolicy(cfg: OpenClawConfig): string[] {
if (groupPolicy === "allowlist" && usesSenderBasedGroupAllowlist(channelName)) {
if (channelName === "telegram" && !hasConfiguredGroups(account, parent)) {
// Fresh Telegram installs default to fail-closed group access until the
// operator explicitly configures allowed groups or sender filters.
const effectiveDmPolicy = dmPolicy ?? "pairing";
const dmSetupLine =
effectiveDmPolicy === "pairing"
? `DMs use pairing mode, so new senders must start a chat and be approved before regular messages are accepted.`
: effectiveDmPolicy === "allowlist"
? `DMs use allowlist mode, so only sender IDs in ${prefix}.allowFrom are accepted.`
: effectiveDmPolicy === "open"
? `DMs are open.`
: `DMs are disabled.`;
warnings.push(
`- ${prefix}: Telegram is in first-time setup mode. ${dmSetupLine} Group messages stay blocked until you add allowed chats under ${prefix}.groups (and optional sender IDs under ${prefix}.groupAllowFrom), or set ${prefix}.groupPolicy to "open" if you want broad group access.`,
);
return;
}
const rawGroupAllowFrom =