Add Version command to AS mode admin room

This replicates the status command output giving version string data in a convenient format to AS Admins.
This commit is contained in:
Catalan Lover
2026-03-26 12:58:01 +01:00
parent 1a4e00edb1
commit c7d52ed044
2 changed files with 50 additions and 0 deletions

View File

@@ -17,10 +17,12 @@ import {
AppserviceListUnstartedCommand,
AppserviceRestartDraupnirCommand,
} from "./ListCommand";
import { AppserviceVersionCommand } from "./VersionCommand";
AppserviceBotCommands.internCommand(AppserviceBotHelpCommand, ["admin", "help"])
.internCommand(AppserviceAllowCommand, ["admin", "allow"])
.internCommand(AppserviceRemoveCommand, ["admin", "remove"])
.internCommand(AppserviceVersionCommand, ["admin", "version"])
.internCommand(AppserviceRestartDraupnirCommand, ["admin", "restart"])
.internCommand(AppserviceListUnstartedCommand, [
"admin",

View File

@@ -0,0 +1,48 @@
// Copyright 2026 Catalan Lover <catalanlover@protonmail.com>
//
// SPDX-License-Identifier: AFL-3.0
import { AppserviceAdaptorContext } from "./AppserviceBotPrerequisite";
import { ActionResult, Ok, isError } from "matrix-protection-suite";
import {
DeadDocumentJSX,
describeCommand,
} from "@the-draupnir-project/interface-manager";
import { AppserviceBotInterfaceAdaptor } from "./AppserviceBotInterfaceAdaptor";
import { CURRENT_BRANCH, SOFTWARE_VERSION } from "../../config";
type AppserviceVersionInfo = {
version: string;
branch: string;
};
export const AppserviceVersionCommand = describeCommand({
summary:
"Show Draupnir version and branch information for this appservice deployment.",
parameters: [],
async executor(
_context: AppserviceAdaptorContext
): Promise<ActionResult<AppserviceVersionInfo>> {
return Ok({
version: SOFTWARE_VERSION,
branch: CURRENT_BRANCH,
});
},
});
AppserviceBotInterfaceAdaptor.describeRenderer(AppserviceVersionCommand, {
JSXRenderer(result) {
if (isError(result)) {
return Ok(undefined);
}
return Ok(
<root>
<b>Version: </b>
<code>{result.ok.version}</code>
<br />
<b>Branch: </b>
<code>{result.ok.branch}</code>
</root>
);
},
});