feat: add session origin metadata helpers

This commit is contained in:
Peter Steinberger
2026-01-18 02:41:23 +00:00
parent 34590d2144
commit 5f22b68268
2 changed files with 147 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import { describe, expect, it } from "vitest";
import { deriveSessionMetaPatch } from "./metadata.js";
describe("deriveSessionMetaPatch", () => {
it("captures origin + group metadata", () => {
const patch = deriveSessionMetaPatch({
ctx: {
Provider: "whatsapp",
ChatType: "group",
GroupSubject: "Family",
From: "123@g.us",
},
sessionKey: "agent:main:whatsapp:group:123@g.us",
});
expect(patch?.origin?.label).toBe("Family id:123@g.us");
expect(patch?.origin?.provider).toBe("whatsapp");
expect(patch?.subject).toBe("Family");
expect(patch?.channel).toBe("whatsapp");
expect(patch?.groupId).toBe("123@g.us");
});
});