mirror of
https://github.com/Routstr/routstrd.git
synced 2026-08-10 20:17:32 +00:00
Merge branch 'main' into fix/remote-mode-clients-list
This commit is contained in:
+14
-1
@@ -10,6 +10,7 @@ import {
|
||||
getNpubSuffix,
|
||||
addDaemonClient,
|
||||
ensureDaemonClient,
|
||||
getUserNpub,
|
||||
} from "./utils/daemon-client";
|
||||
import { getClientsList } from "./utils/clients";
|
||||
import { existsSync, mkdirSync } from "fs";
|
||||
@@ -909,6 +910,8 @@ npubsCmd
|
||||
.description("List configured admin npubs")
|
||||
.action(async () => {
|
||||
await ensureDaemonRunning();
|
||||
const config = await loadConfig();
|
||||
const userNpub = getUserNpub(config);
|
||||
const result = await callDaemon("/npubs");
|
||||
if (result.error) {
|
||||
console.log(result.error);
|
||||
@@ -924,8 +927,18 @@ npubsCmd
|
||||
return;
|
||||
}
|
||||
console.log(`Admin npubs (${npubs.length}):`);
|
||||
let found = false;
|
||||
for (const npub of npubs) {
|
||||
console.log(`- ${npub}`);
|
||||
const marker = npub === userNpub ? " → you" : "";
|
||||
if (npub === userNpub) found = true;
|
||||
console.log(`- ${npub}${marker}`);
|
||||
}
|
||||
if (userNpub && !found) {
|
||||
console.log("");
|
||||
console.log(
|
||||
"Your npub is not in the admin list. Ask the admin to add your npub:",
|
||||
);
|
||||
console.log(` ${userNpub}`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -171,6 +171,16 @@ export function getNpubSuffix(config: RoutstrdConfig): string | null {
|
||||
}
|
||||
}
|
||||
|
||||
export function getUserNpub(config: RoutstrdConfig): string | null {
|
||||
if (!config.nsec) return null;
|
||||
try {
|
||||
const secretKey = parseSecretKey(config.nsec);
|
||||
return npubFromSecretKey(secretKey);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function startDaemonProcess(): Promise<void> {
|
||||
// Ensure logs directory exists (logger handles date-based files)
|
||||
if (!existsSync(LOGS_DIR)) {
|
||||
|
||||
Reference in New Issue
Block a user