mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-23 16:18:13 +00:00
Matrix-js: dedupe monitor types and stabilize verification test
This commit is contained in:
@@ -115,7 +115,7 @@ describe("registerMatrixMonitorEvents verification routing", () => {
|
||||
});
|
||||
|
||||
it("posts SAS emoji/decimal details when verification summaries expose them", async () => {
|
||||
const { sendMessage, roomEventListener } = createHarness({
|
||||
const { sendMessage, roomEventListener, listVerifications } = createHarness({
|
||||
verifications: [
|
||||
{
|
||||
id: "verification-1",
|
||||
@@ -155,7 +155,7 @@ describe("registerMatrixMonitorEvents verification routing", () => {
|
||||
});
|
||||
|
||||
it("does not emit duplicate SAS notices for the same verification payload", async () => {
|
||||
const { sendMessage, roomEventListener } = createHarness({
|
||||
const { sendMessage, roomEventListener, listVerifications } = createHarness({
|
||||
verifications: [
|
||||
{
|
||||
id: "verification-3",
|
||||
@@ -196,7 +196,9 @@ describe("registerMatrixMonitorEvents verification routing", () => {
|
||||
"m.relates_to": { event_id: "$req3" },
|
||||
},
|
||||
});
|
||||
await new Promise((resolve) => setTimeout(resolve, 20));
|
||||
await vi.waitFor(() => {
|
||||
expect(listVerifications).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
const sasBodies = sendMessage.mock.calls
|
||||
.map((call) => String(((call as unknown[])[1] as { body?: string } | undefined)?.body ?? ""))
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
import { getMatrixRuntime } from "../../runtime.js";
|
||||
|
||||
type MessageContentWithMentions = {
|
||||
formatted_body?: string;
|
||||
"m.mentions"?: {
|
||||
user_ids?: string[];
|
||||
room?: boolean;
|
||||
};
|
||||
[key: string]: unknown;
|
||||
};
|
||||
import type { RoomMessageEventContent } from "./types.js";
|
||||
|
||||
/**
|
||||
* Check if the formatted_body contains a matrix.to mention link for the given user ID.
|
||||
@@ -33,7 +25,7 @@ function checkFormattedBodyMention(formattedBody: string | undefined, userId: st
|
||||
}
|
||||
|
||||
export function resolveMentions(params: {
|
||||
content: MessageContentWithMentions;
|
||||
content: RoomMessageEventContent;
|
||||
userId?: string | null;
|
||||
text?: string;
|
||||
mentionRegexes: RegExp[];
|
||||
|
||||
@@ -1,23 +1,5 @@
|
||||
// Type for raw Matrix event payload consumed by thread helpers.
|
||||
type MatrixRawEvent = {
|
||||
event_id: string;
|
||||
sender: string;
|
||||
type: string;
|
||||
origin_server_ts: number;
|
||||
content: Record<string, unknown>;
|
||||
};
|
||||
|
||||
type RoomMessageEventContent = {
|
||||
"m.relates_to"?: {
|
||||
rel_type?: string;
|
||||
event_id?: string;
|
||||
"m.in_reply_to"?: { event_id?: string };
|
||||
};
|
||||
};
|
||||
|
||||
const RelationType = {
|
||||
Thread: "m.thread",
|
||||
} as const;
|
||||
import type { MatrixRawEvent, RoomMessageEventContent } from "./types.js";
|
||||
import { RelationType } from "./types.js";
|
||||
|
||||
export function resolveMatrixThreadTarget(params: {
|
||||
threadReplies: "off" | "inbound" | "always";
|
||||
|
||||
Reference in New Issue
Block a user