Add status update source

This commit is contained in:
Samuel Elliott 2025-04-20 20:55:02 +01:00
parent 90b520c444
commit 059799164d
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
3 changed files with 17 additions and 2 deletions

View File

@ -194,6 +194,13 @@ export async function init() {
app.setAppUserModelId('uk.org.fancy.nxapi.app');
}
import('../../common/remote-config.js').then(m => {
if (!m.default.status_update_url) return;
appinstance.statusupdates.addSource(m.default.status_update_url);
}).catch(err => {
debug('error adding status update source from remote config', err);
});
appinstance.statusupdates.subscribe({
onUpdate: data => sendToAllWindows('nxapi:statusupdates', data),
});

View File

@ -12,6 +12,10 @@ export function builder(yargs: Argv<ParentArguments>) {
return yargs.option('url', {
describe: 'Additional status update source',
type: 'array',
}).option('use-config', {
describe: 'Use the status update source from nxapi\'s remote configuration',
type: 'boolean',
default: true,
}).option('json', {
describe: 'Output raw JSON',
type: 'boolean',
@ -24,10 +28,13 @@ export function builder(yargs: Argv<ParentArguments>) {
type Arguments = YargsArguments<ReturnType<typeof builder>>;
export async function handler(argv: ArgumentsCamelCase<Arguments>) {
// const { default: config } = await import('../../common/remote-config.js');
const status = new StatusUpdateMonitor();
if (argv.useConfig) {
const { default: config } = await import('../../common/remote-config.js');
if (config.status_update_url) status.addSource(config.status_update_url);
}
for (const url of argv.url ?? []) {
status.addSource(url.toString());
}

View File

@ -251,6 +251,7 @@ export interface NxapiRemoteConfig {
*/
require_version: string[];
status_update_url?: string;
log_encryption_key?: string;
// If null the API should not be used