fix(zalouser): fix group mention detection failures

- Deduplicate mention IDs via Set in extractMentionIds
- Add fallback to getOwnId when fetchAccountInfo shape changes
- Narrow fetchAccountInfo return type to { profile: User }
- Fail closed when requireMention=true but detection unavailable
- Add test for mention-unavailable fail-closed behavior
This commit is contained in:
Tom
2026-03-03 12:39:49 +07:00
parent 12b52aa3a7
commit 98bc429c1a
2 changed files with 20 additions and 1 deletions

View File

@@ -170,6 +170,25 @@ describe("zalouser monitor group mention gating", () => {
expect(sendTypingZalouserMock).not.toHaveBeenCalled();
});
it("fails closed when requireMention=true but mention detection is unavailable", async () => {
const { dispatchReplyWithBufferedBlockDispatcher } = installRuntime({
commandAuthorized: false,
});
await __testing.processMessage({
message: createGroupMessage({
canResolveExplicitMention: false,
hasAnyMention: false,
wasExplicitlyMentioned: false,
}),
account: createAccount(),
config: createConfig(),
runtime: createRuntimeEnv(),
});
expect(dispatchReplyWithBufferedBlockDispatcher).not.toHaveBeenCalled();
expect(sendTypingZalouserMock).not.toHaveBeenCalled();
});
it("dispatches explicitly-mentioned group messages and marks WasMentioned", async () => {
const { dispatchReplyWithBufferedBlockDispatcher } = installRuntime({
commandAuthorized: false,

View File

@@ -138,7 +138,7 @@ export type API = {
cookies: unknown[];
};
};
fetchAccountInfo(): Promise<{ profile: User } | User>;
fetchAccountInfo(): Promise<{ profile: User }>;
getAllFriends(): Promise<User[]>;
getOwnId(): string;
getAllGroups(): Promise<{