fix: preserve unmatched telegram access groups

This commit is contained in:
Peter Steinberger
2026-05-07 05:38:27 +01:00
parent d033c369c6
commit 23920f6160
2 changed files with 30 additions and 1 deletions

View File

@@ -28,5 +28,9 @@ export async function expandTelegramAllowFromWithAccessGroups(params: {
}),
})
: allowFrom;
return expanded.filter((entry) => parseAccessGroupAllowFromEntry(entry) == null);
const originalEntries = new Set(allowFrom);
const matched = expanded.some((entry) => !originalEntries.has(entry));
return matched
? expanded.filter((entry) => parseAccessGroupAllowFromEntry(entry) == null)
: expanded;
}

View File

@@ -1609,6 +1609,31 @@ describe("createTelegramBot", () => {
},
expectedReplyCount: 1,
},
{
name: "blocks explicitly configured group when groupAllowFrom access group does not match sender",
config: {
accessGroups: {
operators: {
type: "message.senders",
members: { telegram: ["111111111"] },
},
},
channels: {
telegram: {
groupPolicy: "allowlist",
groupAllowFrom: ["accessGroup:operators"],
groups: { "-100123456789": { requireMention: false } },
},
},
},
message: {
chat: { id: -100123456789, type: "group", title: "Test Group" },
from: { id: 123456789, username: "testuser" },
text: "hello",
date: 1736380800,
},
expectedReplyCount: 0,
},
{
name: "allows group messages from sender access groups in per-group allowFrom",
config: {