fix: skip dm history limit for non-dm sessions
This commit is contained in:
@@ -399,6 +399,19 @@ describe("getDmHistoryLimitFromSessionKey", () => {
|
|||||||
).toBe(10);
|
).toBe(10);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("returns undefined for non-dm session kinds", () => {
|
||||||
|
const config = {
|
||||||
|
slack: { dmHistoryLimit: 10 },
|
||||||
|
telegram: { dmHistoryLimit: 15 },
|
||||||
|
} as ClawdbotConfig;
|
||||||
|
expect(
|
||||||
|
getDmHistoryLimitFromSessionKey("agent:beta:slack:channel:C1", config),
|
||||||
|
).toBeUndefined();
|
||||||
|
expect(
|
||||||
|
getDmHistoryLimitFromSessionKey("telegram:slash:123", config),
|
||||||
|
).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
it("returns undefined for unknown provider", () => {
|
it("returns undefined for unknown provider", () => {
|
||||||
const config = { telegram: { dmHistoryLimit: 15 } } as ClawdbotConfig;
|
const config = { telegram: { dmHistoryLimit: 15 } } as ClawdbotConfig;
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -475,6 +475,7 @@ export function getDmHistoryLimitFromSessionKey(
|
|||||||
// The userId may contain colons (e.g., email addresses), so join remaining parts
|
// The userId may contain colons (e.g., email addresses), so join remaining parts
|
||||||
const kind = providerParts[1]?.toLowerCase();
|
const kind = providerParts[1]?.toLowerCase();
|
||||||
const userId = providerParts.slice(2).join(":");
|
const userId = providerParts.slice(2).join(":");
|
||||||
|
if (kind !== "dm") return undefined;
|
||||||
|
|
||||||
// Helper to get limit with per-DM override support
|
// Helper to get limit with per-DM override support
|
||||||
const getLimit = (
|
const getLimit = (
|
||||||
|
|||||||
Reference in New Issue
Block a user