fixed the suffix not being added bug.

This commit is contained in:
redshift
2026-04-30 13:59:14 +05:30
parent 240706f6f1
commit 9628c6bfbd
+8 -9
View File
@@ -121,12 +121,15 @@ export async function getClientsList(): Promise<ClientEntry[]> {
export async function addDaemonClient(
name: string,
clientId?: string,
): Promise<{ message?: string; client: DaemonClient; created: boolean }> {
const existingClients = await getClientsList();
const existing = clientId
? existingClients.find((c) => c.clientId === clientId)
: existingClients.find((c) => c.name === name);
// Derive id from name by replacing spaces with hyphens
const derivedId = name.replace(/\s+/g, "-").toLowerCase();
const config = await loadConfig();
const suffix = getNpubSuffix(config);
const clientId = suffix ? addSuffixToId(derivedId, suffix) : derivedId;
const existing = existingClients.find((c) => c.clientId === clientId);
if (existing) {
const client: DaemonClient = {
@@ -139,9 +142,6 @@ export async function addDaemonClient(
return { client, created: false };
}
// Derive id from name by replacing spaces with hyphens
const derivedId = name.replace(/\s+/g, "-").toLowerCase();
const result = await callDaemon("/clients/add", {
method: "POST",
body: { name, id: derivedId },
@@ -246,8 +246,7 @@ export async function addClientAction(options: AddClientOptions): Promise<void>
try {
const { client, created } = await addDaemonClient(
integrationConfig.name,
integrationConfig.clientId,
integrationConfig.name
);
if (created) {
logger.log(`Created new API key for ${integrationConfig.name}`);