build: add local node bin to restart script PATH

This commit is contained in:
Peter Steinberger
2025-12-07 18:49:55 +01:00
parent 558af7a454
commit d463c82c95
31 changed files with 2089 additions and 1851 deletions
+20
View File
@@ -44,6 +44,15 @@ export type WebConfig = {
reconnect?: WebReconnectConfig;
};
export type TelegramConfig = {
botToken?: string;
requireMention?: boolean;
allowFrom?: Array<string | number>;
mediaMaxMb?: number;
proxy?: string;
webhookUrl?: string;
};
export type GroupChatConfig = {
requireMention?: boolean;
mentionPatterns?: string[];
@@ -89,6 +98,7 @@ export type WarelayConfig = {
};
};
web?: WebConfig;
telegram?: TelegramConfig;
};
// New branding path (preferred)
@@ -214,6 +224,16 @@ const WarelaySchema = z.object({
.optional(),
})
.optional(),
telegram: z
.object({
botToken: z.string().optional(),
requireMention: z.boolean().optional(),
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
mediaMaxMb: z.number().positive().optional(),
proxy: z.string().optional(),
webhookUrl: z.string().optional(),
})
.optional(),
});
export function loadConfig(): WarelayConfig {
+18
View File
@@ -23,12 +23,30 @@ describe("sessions", () => {
);
});
it("collapses direct chats to main by default", () => {
expect(resolveSessionKey("per-sender", { From: "+1555" })).toBe("main");
});
it("collapses direct chats to main even when sender missing", () => {
expect(resolveSessionKey("per-sender", {})).toBe("main");
});
it("maps direct chats to main key when provided", () => {
expect(
resolveSessionKey("per-sender", { From: "whatsapp:+1555" }, "main"),
).toBe("main");
});
it("uses custom main key when provided", () => {
expect(resolveSessionKey("per-sender", { From: "+1555" }, "primary")).toBe(
"primary",
);
});
it("keeps global scope untouched", () => {
expect(resolveSessionKey("global", { From: "+1555" })).toBe("global");
});
it("leaves groups untouched even with main key", () => {
expect(
resolveSessionKey("per-sender", { From: "12345-678@g.us" }, "main"),
+5 -4
View File
@@ -79,8 +79,8 @@ export function deriveSessionKey(scope: SessionScope, ctx: MsgContext) {
}
/**
* Resolve the session key with an optional canonical direct-chat key (e.g., "main").
* All non-group direct chats collapse to `mainKey` when provided, keeping group isolation.
* Resolve the session key with a canonical direct-chat bucket (default: "main").
* All non-group direct chats collapse to this bucket; groups stay isolated.
*/
export function resolveSessionKey(
scope: SessionScope,
@@ -89,8 +89,9 @@ export function resolveSessionKey(
) {
const raw = deriveSessionKey(scope, ctx);
if (scope === "global") return raw;
const canonical = (mainKey ?? "").trim();
// Default to a single shared direct-chat session called "main"; groups stay isolated.
const canonical = (mainKey ?? "main").trim() || "main";
const isGroup = raw.startsWith("group:") || raw.includes("@g.us");
if (!isGroup && canonical) return canonical;
if (!isGroup) return canonical;
return raw;
}