Add Signal auto-group creation

This commit is contained in:
Darren Clarke 2025-06-10 14:02:21 +02:00
parent a83907b4be
commit c8ccee7ada
7 changed files with 393 additions and 8 deletions

View file

@ -0,0 +1,120 @@
#!/usr/bin/env node
import { config } from "dotenv";
import * as signalApi from "@link-stack/signal-api";
// Load environment variables
config();
const { Configuration, GroupsApi, MessagesApi } = signalApi;
async function testSignalGroups() {
console.log("Signal Groups Test Script");
console.log("=========================\n");
// Check environment
const autoGroupsEnabled = process.env.BRIDGE_SIGNAL_AUTO_GROUPS === "true";
console.log(`Auto-groups enabled: ${autoGroupsEnabled}`);
console.log(`Signal API URL: ${process.env.BRIDGE_SIGNAL_URL}\n`);
if (!process.env.BRIDGE_SIGNAL_URL) {
console.error("Error: BRIDGE_SIGNAL_URL not set");
process.exit(1);
}
try {
const config = new Configuration({
basePath: process.env.BRIDGE_SIGNAL_URL,
});
const groupsClient = new GroupsApi(config);
const messagesClient = new MessagesApi(config);
// List existing groups
console.log("Listing existing groups...");
const groups = await groupsClient.v1GroupsNumberGet({
number: process.env.BRIDGE_SIGNAL_BOT_NUMBER,
});
console.log(`Found ${groups.length} groups:`);
groups.forEach((group, i) => {
console.log(` ${i + 1}. ${group.name} (${group.id})`);
console.log(` Members: ${group.members?.length || 0}`);
});
console.log();
// Test creating a group (if requested via command line)
if (process.argv.includes("--create-group")) {
const testNumber = process.argv[process.argv.indexOf("--create-group") + 1];
if (!testNumber) {
console.error("Error: Please provide a phone number after --create-group");
process.exit(1);
}
console.log(`Creating test group with ${testNumber}...`);
const createResponse = await groupsClient.v1GroupsNumberPost({
number: process.env.BRIDGE_SIGNAL_BOT_NUMBER,
data: {
name: `Test Support: ${testNumber}`,
members: [testNumber],
description: "Test private support conversation",
},
});
console.log(`Created group: ${createResponse.id}\n`);
// Send a test message to the group
if (process.argv.includes("--send-message")) {
console.log("Sending test message to group...");
await messagesClient.v2SendPost({
data: {
number: process.env.BRIDGE_SIGNAL_BOT_NUMBER,
recipients: [createResponse.id!],
message: "Hello! This is a test message to the new Signal group.",
isGroup: true,
},
});
console.log("Message sent successfully!\n");
}
}
// Test the receive flow simulation
if (process.argv.includes("--simulate-receive")) {
const fromNumber = process.argv[process.argv.indexOf("--simulate-receive") + 1];
if (!fromNumber) {
console.error("Error: Please provide a phone number after --simulate-receive");
process.exit(1);
}
console.log(`Simulating message receive from ${fromNumber}...`);
console.log("This would trigger the following in production:");
console.log("1. Message received from individual");
console.log("2. Auto-group creation (if enabled)");
console.log("3. Webhook notification to Zammad with group ID in 'to' field\n");
if (autoGroupsEnabled) {
console.log("Since auto-groups is enabled, a new group would be created.");
console.log(`Group name would be: Support: ${fromNumber}`);
} else {
console.log("Auto-groups is disabled, so message would be processed normally.");
}
}
console.log("\nTest script completed successfully!");
} catch (error) {
console.error("Error during test:", error);
process.exit(1);
}
}
// Show usage if no arguments
if (process.argv.length === 2) {
console.log("Usage:");
console.log(" List groups: ts-node test-signal-groups.ts");
console.log(" Create group: ts-node test-signal-groups.ts --create-group +1234567890");
console.log(" Create & send: ts-node test-signal-groups.ts --create-group +1234567890 --send-message");
console.log(" Simulate receive: ts-node test-signal-groups.ts --simulate-receive +1234567890");
console.log("\nEnvironment variables:");
console.log(" BRIDGE_SIGNAL_AUTO_GROUPS=true Enable auto-group creation");
console.log(" BRIDGE_SIGNAL_URL=http://... Signal CLI REST API URL");
process.exit(0);
}
testSignalGroups().catch(console.error);

View file

@ -48,6 +48,12 @@ const processMessage = async ({
const { envelope } = msg; const { envelope } = msg;
const { source, sourceUuid, dataMessage } = envelope; const { source, sourceUuid, dataMessage } = envelope;
const isGroup = !!(
dataMessage?.groupV2 ||
dataMessage?.groupContext ||
dataMessage?.groupInfo
);
if (!dataMessage) return []; if (!dataMessage) return [];
const { attachments } = dataMessage; const { attachments } = dataMessage;
@ -67,6 +73,7 @@ const processMessage = async ({
attachment: primaryAttachment.attachment, attachment: primaryAttachment.attachment,
filename: primaryAttachment.filename, filename: primaryAttachment.filename,
mimeType: primaryAttachment.mimeType, mimeType: primaryAttachment.mimeType,
isGroup,
}; };
const formattedMessages = [primaryMessage]; const formattedMessages = [primaryMessage];

View file

@ -1,4 +1,6 @@
import { db, getWorkerUtils } from "@link-stack/bridge-common"; import { db, getWorkerUtils } from "@link-stack/bridge-common";
import * as signalApi from "@link-stack/signal-api";
const { Configuration, GroupsApi } = signalApi;
interface ReceiveSignalMessageTaskOptions { interface ReceiveSignalMessageTaskOptions {
token: string; token: string;
@ -10,6 +12,7 @@ interface ReceiveSignalMessageTaskOptions {
attachment?: string; attachment?: string;
filename?: string; filename?: string;
mimeType?: string; mimeType?: string;
isGroup?: boolean;
} }
const receiveSignalMessageTask = async ({ const receiveSignalMessageTask = async ({
@ -22,6 +25,7 @@ const receiveSignalMessageTask = async ({
attachment, attachment,
filename, filename,
mimeType, mimeType,
isGroup,
}: ReceiveSignalMessageTaskOptions): Promise<void> => { }: ReceiveSignalMessageTaskOptions): Promise<void> => {
const worker = await getWorkerUtils(); const worker = await getWorkerUtils();
const row = await db const row = await db
@ -31,8 +35,43 @@ const receiveSignalMessageTask = async ({
.executeTakeFirstOrThrow(); .executeTakeFirstOrThrow();
const backendId = row.id; const backendId = row.id;
let finalTo = to;
// Check if auto-group creation is enabled and this is NOT already a group message
const enableAutoGroups = process.env.BRIDGE_SIGNAL_AUTO_GROUPS === "true";
if (enableAutoGroups && !isGroup && from && to) {
try {
const config = new Configuration({
basePath: process.env.BRIDGE_SIGNAL_URL,
});
const groupsClient = new GroupsApi(config);
// Create new group for this conversation
const groupName = `Support: ${from}`;
const createGroupResponse = await groupsClient.v1GroupsNumberPost({
number: row.phoneNumber,
data: {
name: groupName,
members: [from],
description: "Private support conversation",
},
});
if (createGroupResponse.id) {
finalTo = createGroupResponse.id;
console.log(
`Created new Signal group ${finalTo} for conversation with ${from}`,
);
}
} catch (error) {
console.error("Error creating Signal group:", error);
// Continue with original 'to' if group creation fails
}
}
const payload = { const payload = {
to, to: finalTo,
from, from,
message_id: messageId, message_id: messageId,
sent_at: sentAt, sent_at: sentAt,

View file

@ -1,17 +1,19 @@
import { db } from "@link-stack/bridge-common"; import { db, getWorkerUtils } from "@link-stack/bridge-common";
import * as signalApi from "@link-stack/signal-api"; import * as signalApi from "@link-stack/signal-api";
const { Configuration, MessagesApi } = signalApi; const { Configuration, MessagesApi, GroupsApi } = signalApi;
interface SendSignalMessageTaskOptions { interface SendSignalMessageTaskOptions {
token: string; token: string;
to: string; to: string;
message: any; message: any;
conversationId?: string; // Zammad ticket/conversation ID for callback
} }
const sendSignalMessageTask = async ({ const sendSignalMessageTask = async ({
token, token,
to, to,
message, message,
conversationId,
}: SendSignalMessageTaskOptions): Promise<void> => { }: SendSignalMessageTaskOptions): Promise<void> => {
const bot = await db const bot = await db
.selectFrom("SignalBot") .selectFrom("SignalBot")
@ -24,15 +26,69 @@ const sendSignalMessageTask = async ({
basePath: process.env.BRIDGE_SIGNAL_URL, basePath: process.env.BRIDGE_SIGNAL_URL,
}); });
const messagesClient = new MessagesApi(config); const messagesClient = new MessagesApi(config);
const groupsClient = new GroupsApi(config);
const worker = await getWorkerUtils();
let finalTo = to;
let groupCreated = false;
try { try {
// Check if 'to' is a group ID (UUID format) vs phone number
const isGroupId =
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
to,
);
const enableAutoGroups = process.env.BRIDGE_SIGNAL_AUTO_GROUPS === "true";
// If sending to a phone number and auto-groups is enabled, create a group first
if (enableAutoGroups && !isGroupId && to && conversationId) {
try {
const groupName = `Support: ${to}`;
const createGroupResponse = await groupsClient.v1GroupsNumberPost({
number: bot.phoneNumber,
data: {
name: groupName,
members: [to],
description: "Private support conversation",
},
});
if (createGroupResponse.id) {
finalTo = createGroupResponse.id;
groupCreated = true;
console.log(
`Created new Signal group ${finalTo} for conversation ${conversationId} with ${to}`,
);
// Notify Zammad about the new group ID via webhook
await worker.addJob("common/notify-webhooks", {
backendId: bot.id,
payload: {
event: "group_created",
conversation_id: conversationId,
original_recipient: to,
group_id: finalTo,
timestamp: new Date().toISOString(),
},
});
}
} catch (groupError) {
console.error("Error creating Signal group:", groupError);
// Continue with original recipient if group creation fails
}
}
const response = await messagesClient.v2SendPost({ const response = await messagesClient.v2SendPost({
data: { data: {
number, number,
recipients: [to], recipients: [finalTo],
message, message,
}, },
}); });
console.log(
`Message sent successfully to ${finalTo}${groupCreated ? " (new group)" : ""}`,
);
} catch (error) { } catch (error) {
console.error({ error }); console.error({ error });
throw error; throw error;

159
package-lock.json generated
View file

@ -19,6 +19,7 @@
"eslint": "^9", "eslint": "^9",
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
"ts-node": "^10.9.2",
"turbo": "^2.4.4", "turbo": "^2.4.4",
"typescript": "latest" "typescript": "latest"
}, },
@ -197,6 +198,7 @@
"@link-stack/typescript-config": "*", "@link-stack/typescript-config": "*",
"@types/fluent-ffmpeg": "^2.1.27", "@types/fluent-ffmpeg": "^2.1.27",
"dotenv-cli": "^8.0.0", "dotenv-cli": "^8.0.0",
"ts-node": "^10.9.2",
"typescript": "^5.8.2" "typescript": "^5.8.2"
} }
}, },
@ -1029,6 +1031,30 @@
"integrity": "sha512-016mBJD3DESw7Nh+lkKcPd22xG92ghA0VpIXIbjQtmXhC7Ve6wRazTy8z1Ahut+Tbv179+JxrftuMngsj/yV8Q==", "integrity": "sha512-016mBJD3DESw7Nh+lkKcPd22xG92ghA0VpIXIbjQtmXhC7Ve6wRazTy8z1Ahut+Tbv179+JxrftuMngsj/yV8Q==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/@cspotcode/source-map-support": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
"devOptional": true,
"license": "MIT",
"dependencies": {
"@jridgewell/trace-mapping": "0.3.9"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": {
"version": "0.3.9",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
"devOptional": true,
"license": "MIT",
"dependencies": {
"@jridgewell/resolve-uri": "^3.0.3",
"@jridgewell/sourcemap-codec": "^1.4.10"
}
},
"node_modules/@emnapi/runtime": { "node_modules/@emnapi/runtime": {
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.3.1.tgz", "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.3.1.tgz",
@ -4720,6 +4746,34 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/@tsconfig/node10": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz",
"integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==",
"devOptional": true,
"license": "MIT"
},
"node_modules/@tsconfig/node12": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
"integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==",
"devOptional": true,
"license": "MIT"
},
"node_modules/@tsconfig/node14": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
"integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
"devOptional": true,
"license": "MIT"
},
"node_modules/@tsconfig/node16": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz",
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
"devOptional": true,
"license": "MIT"
},
"node_modules/@types/babel__core": { "node_modules/@types/babel__core": {
"version": "7.20.5", "version": "7.20.5",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",
@ -5553,6 +5607,19 @@
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
} }
}, },
"node_modules/acorn-walk": {
"version": "8.3.4",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz",
"integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==",
"devOptional": true,
"license": "MIT",
"dependencies": {
"acorn": "^8.11.0"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/agent-base": { "node_modules/agent-base": {
"version": "7.1.3", "version": "7.1.3",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz",
@ -5631,6 +5698,13 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/arg": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
"devOptional": true,
"license": "MIT"
},
"node_modules/argparse": { "node_modules/argparse": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
@ -6994,6 +7068,13 @@
"node": "^14.15.0 || ^16.10.0 || >=18.0.0" "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
} }
}, },
"node_modules/create-require": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
"devOptional": true,
"license": "MIT"
},
"node_modules/cross-spawn": { "node_modules/cross-spawn": {
"version": "7.0.6", "version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
@ -7332,6 +7413,16 @@
"url": "https://github.com/sponsors/wooorm" "url": "https://github.com/sponsors/wooorm"
} }
}, },
"node_modules/diff": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
"devOptional": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/diff-sequences": { "node_modules/diff-sequences": {
"version": "29.6.3", "version": "29.6.3",
"resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz",
@ -11655,6 +11746,13 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/make-error": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
"devOptional": true,
"license": "ISC"
},
"node_modules/makeerror": { "node_modules/makeerror": {
"version": "1.0.12", "version": "1.0.12",
"resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz",
@ -15873,6 +15971,50 @@
"typescript": ">=4.8.4" "typescript": ">=4.8.4"
} }
}, },
"node_modules/ts-node": {
"version": "10.9.2",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz",
"integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==",
"devOptional": true,
"license": "MIT",
"dependencies": {
"@cspotcode/source-map-support": "^0.8.0",
"@tsconfig/node10": "^1.0.7",
"@tsconfig/node12": "^1.0.7",
"@tsconfig/node14": "^1.0.0",
"@tsconfig/node16": "^1.0.2",
"acorn": "^8.4.1",
"acorn-walk": "^8.1.1",
"arg": "^4.1.0",
"create-require": "^1.1.0",
"diff": "^4.0.1",
"make-error": "^1.1.1",
"v8-compile-cache-lib": "^3.0.1",
"yn": "3.1.1"
},
"bin": {
"ts-node": "dist/bin.js",
"ts-node-cwd": "dist/bin-cwd.js",
"ts-node-esm": "dist/bin-esm.js",
"ts-node-script": "dist/bin-script.js",
"ts-node-transpile-only": "dist/bin-transpile.js",
"ts-script": "dist/bin-script-deprecated.js"
},
"peerDependencies": {
"@swc/core": ">=1.2.50",
"@swc/wasm": ">=1.2.50",
"@types/node": "*",
"typescript": ">=2.7"
},
"peerDependenciesMeta": {
"@swc/core": {
"optional": true
},
"@swc/wasm": {
"optional": true
}
}
},
"node_modules/tsconfig-paths": { "node_modules/tsconfig-paths": {
"version": "3.15.0", "version": "3.15.0",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz",
@ -16457,6 +16599,13 @@
"uuid": "dist/esm/bin/uuid" "uuid": "dist/esm/bin/uuid"
} }
}, },
"node_modules/v8-compile-cache-lib": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
"devOptional": true,
"license": "MIT"
},
"node_modules/v8-to-istanbul": { "node_modules/v8-to-istanbul": {
"version": "9.3.0", "version": "9.3.0",
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz",
@ -16835,6 +16984,16 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/yn": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
"devOptional": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/yocto-queue": { "node_modules/yocto-queue": {
"version": "0.1.0", "version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",

View file

@ -51,13 +51,14 @@
"author": "Darren Clarke", "author": "Darren Clarke",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"devDependencies": { "devDependencies": {
"@types/react": "^19.0.12",
"dotenv-cli": "latest", "dotenv-cli": "latest",
"eslint": "^9", "eslint": "^9",
"turbo": "^2.4.4",
"typescript": "latest",
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
"@types/react": "^19.0.12" "ts-node": "^10.9.2",
"turbo": "^2.4.4",
"typescript": "latest"
}, },
"overrides": { "overrides": {
"material-ui-popup-state": { "material-ui-popup-state": {

View file

@ -1,7 +1,10 @@
import { ServiceConfig } from "../lib/service"; import { ServiceConfig } from "../lib/service";
const getQRCode = async (token: string): Promise<Record<string, string>> => { const getQRCode = async (token: string): Promise<Record<string, string>> => {
const url = `/link/api/signal/bots/${token}`; const basePath = window?.location?.pathname?.startsWith("/link")
? "/link"
: "";
const url = `${basePath}/api/signal/bots/${token}`;
const result = await fetch(url, { cache: "no-store" }); const result = await fetch(url, { cache: "no-store" });
const { qr } = await result.json(); const { qr } = await result.json();