

























@@ -130,6 +130,29 @@ describe("resolveWhatsAppOutboundTarget", () => {
130130});
131131});
132132133+describe("newsletter JID handling", () => {
134+it("returns success for valid newsletter JID without applying DM allowFrom", () => {
135+vi.mocked(normalize.normalizeWhatsAppTarget).mockReturnValueOnce(
136+"120363123456789@newsletter",
137+);
138+vi.mocked(normalize.isWhatsAppGroupJid).mockReturnValueOnce(false);
139+vi.mocked(normalize.isWhatsAppNewsletterJid).mockReturnValueOnce(true);
140+141+expectResolutionOk(
142+{
143+to: "120363123456789@newsletter",
144+allowFrom: [SECONDARY_TARGET],
145+mode: "implicit",
146+},
147+"120363123456789@newsletter",
148+);
149+expect(vi.mocked(normalize.normalizeWhatsAppTarget)).toHaveBeenCalledOnce();
150+expect(vi.mocked(normalize.normalizeWhatsAppTarget)).toHaveBeenCalledWith(
151+"120363123456789@newsletter",
152+);
153+});
154+});
155+133156describe("implicit/heartbeat mode with allowList", () => {
134157it("allows message when wildcard is present", () => {
135158mockNormalizedDirectMessage(PRIMARY_TARGET, PRIMARY_TARGET);
@@ -154,14 +177,14 @@ describe("resolveWhatsAppOutboundTarget", () => {
154177allowFrom: [SECONDARY_TARGET],
155178mode: "implicit",
156179},
157-`Target "${SECONDARY_TARGET}" is not listed in the configured WhatsApp allowFrom policy.`,
180+`Target "${PRIMARY_TARGET}" is not listed in the configured WhatsApp allowFrom policy.`,
158181);
159182});
160183161184it("uses the normalized target in the allowFrom error message", () => {
162185vi.mocked(normalize.normalizeWhatsAppTarget)
163-.mockReturnValueOnce(SECONDARY_TARGET)
164-.mockReturnValueOnce(PRIMARY_TARGET);
186+.mockReturnValueOnce(PRIMARY_TARGET)
187+.mockReturnValueOnce(SECONDARY_TARGET);
165188vi.mocked(normalize.isWhatsAppGroupJid).mockReturnValueOnce(false);
166189167190expectResolutionErrorMessage(
@@ -189,8 +212,8 @@ describe("resolveWhatsAppOutboundTarget", () => {
189212190213it("filters out invalid normalized entries from allowList", () => {
191214vi.mocked(normalize.normalizeWhatsAppTarget)
192-.mockReturnValueOnce(null)
193215.mockReturnValueOnce("+11234567890")
216+.mockReturnValueOnce(null)
194217.mockReturnValueOnce("+11234567890");
195218vi.mocked(normalize.isWhatsAppGroupJid).mockReturnValueOnce(false);
196219此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。