feat: unify group policy allowlists
This commit is contained in:
@@ -266,10 +266,13 @@ describe("monitorIMessageProvider", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("honors allowFrom entries", async () => {
|
||||
it("honors group allowlist when groupPolicy is allowlist", async () => {
|
||||
config = {
|
||||
...config,
|
||||
imessage: { allowFrom: ["chat_id:101"] },
|
||||
imessage: {
|
||||
groupPolicy: "allowlist",
|
||||
groupAllowFrom: ["chat_id:101"],
|
||||
},
|
||||
};
|
||||
const run = monitorIMessageProvider();
|
||||
await waitForSubscribe();
|
||||
@@ -295,6 +298,35 @@ describe("monitorIMessageProvider", () => {
|
||||
expect(replyMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("blocks group messages when groupPolicy is disabled", async () => {
|
||||
config = {
|
||||
...config,
|
||||
imessage: { groupPolicy: "disabled" },
|
||||
};
|
||||
const run = monitorIMessageProvider();
|
||||
await waitForSubscribe();
|
||||
|
||||
notificationHandler?.({
|
||||
method: "message",
|
||||
params: {
|
||||
message: {
|
||||
id: 10,
|
||||
chat_id: 303,
|
||||
sender: "+15550003333",
|
||||
is_from_me: false,
|
||||
text: "@clawd hi",
|
||||
is_group: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await flush();
|
||||
closeResolve?.();
|
||||
await run;
|
||||
|
||||
expect(replyMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("updates last route with chat_id for direct messages", async () => {
|
||||
replyMock.mockResolvedValueOnce({ text: "ok" });
|
||||
const run = monitorIMessageProvider();
|
||||
|
||||
Reference in New Issue
Block a user