mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-22 23:41:07 +00:00
fix(doctor): add telegram first-run guidance
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user