mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 19:58:27 +00:00
refactor(sessions): add provider key normalizers
This commit is contained in:
@@ -2,6 +2,16 @@ import { describe, expect, it } from "vitest";
|
||||
import { normalizeExplicitDiscordSessionKey } from "./session-key-normalization.js";
|
||||
|
||||
describe("normalizeExplicitDiscordSessionKey", () => {
|
||||
it("rewrites bare discord:dm keys for direct chats", () => {
|
||||
expect(
|
||||
normalizeExplicitDiscordSessionKey("discord:dm:123456", {
|
||||
ChatType: "direct",
|
||||
From: "discord:123456",
|
||||
SenderId: "123456",
|
||||
}),
|
||||
).toBe("discord:direct:123456");
|
||||
});
|
||||
|
||||
it("rewrites legacy discord:dm keys for direct chats", () => {
|
||||
expect(
|
||||
normalizeExplicitDiscordSessionKey("agent:fina:discord:dm:123456", {
|
||||
|
||||
@@ -10,6 +10,7 @@ export function normalizeExplicitDiscordSessionKey(
|
||||
return normalized;
|
||||
}
|
||||
|
||||
normalized = normalized.replace(/^(discord:)dm:/, "$1direct:");
|
||||
normalized = normalized.replace(/^(agent:[^:]+:discord:)dm:/, "$1direct:");
|
||||
const match = normalized.match(/^((?:agent:[^:]+:)?)discord:channel:([^:]+)$/);
|
||||
if (!match) {
|
||||
|
||||
Reference in New Issue
Block a user