fix: align open DM allowlist policy (#74112)

* fix: harden telegram open dm allowlist merging

* fix: align open dm allowlist policy
This commit is contained in:
Peter Steinberger
2026-04-29 06:52:12 +01:00
committed by GitHub
parent fda8cc2a9d
commit bd1d1f0f2b
61 changed files with 740 additions and 262 deletions

View File

@@ -292,6 +292,7 @@ function createLineWebhookTestContext(params: {
const lineConfig = {
...(params.groupPolicy ? { groupPolicy: params.groupPolicy } : {}),
...(params.dmPolicy ? { dmPolicy: params.dmPolicy } : {}),
...(params.dmPolicy === "open" ? { allowFrom: ["*"] } : {}),
};
return {
cfg: { channels: { line: lineConfig } },
@@ -830,14 +831,14 @@ describe("handleLineWebhookEvents", () => {
} as PostbackEvent;
const context: Parameters<typeof handleLineWebhookEvents>[1] = {
cfg: { channels: { line: { dmPolicy: "open" } } },
cfg: { channels: { line: { dmPolicy: "open", allowFrom: ["*"] } } },
account: {
accountId: "default",
enabled: true,
channelAccessToken: "token",
channelSecret: "secret",
tokenSource: "config",
config: { dmPolicy: "open" },
config: { dmPolicy: "open", allowFrom: ["*"] },
},
runtime: createRuntime(),
mediaMaxBytes: 1,

View File

@@ -335,7 +335,7 @@ async function shouldProcessLineEvent(
return denied;
}
const dmAllowed = dmPolicy === "open" || isSenderAllowed({ allow: effectiveDmAllow, senderId });
const dmAllowed = isSenderAllowed({ allow: effectiveDmAllow, senderId });
if (!dmAllowed) {
if (dmPolicy === "pairing") {
if (!senderId) {