mirror of
https://github.com/Routstr/routstrd.git
synced 2026-08-11 20:47:58 +00:00
Merge pull request #17 from Routstr/feature/highlight-user-npub
Feature/highlight user npub
This commit is contained in:
+14
-1
@@ -9,6 +9,7 @@ import {
|
||||
getDaemonBaseUrl,
|
||||
getNpubSuffix,
|
||||
addDaemonClient,
|
||||
getUserNpub,
|
||||
} from "./utils/daemon-client";
|
||||
import { existsSync, mkdirSync } from "fs";
|
||||
import { execSync } from "child_process";
|
||||
@@ -911,6 +912,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);
|
||||
@@ -926,8 +929,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}`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -136,6 +136,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