mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-09-01 16:48:27 +00:00
Print status information when booting from and to safe mode.
This commit is contained in:
@@ -171,7 +171,8 @@ export class DraupnirBotModeToggle implements SafeModeToggle {
|
||||
return draupnirResult;
|
||||
}
|
||||
public async switchToSafeMode(
|
||||
cause: SafeModeCause
|
||||
cause: SafeModeCause,
|
||||
options?: SafeModeToggleOptions
|
||||
): Promise<Result<SafeModeDraupnir>> {
|
||||
if (this.safeModeDraupnir !== null) {
|
||||
return ResultError.Result(
|
||||
@@ -192,6 +193,9 @@ export class DraupnirBotModeToggle implements SafeModeToggle {
|
||||
this.draupnir = null;
|
||||
this.safeModeDraupnir = safeModeResult.ok;
|
||||
this.safeModeDraupnir.start();
|
||||
if (options?.sendStatusOnStart) {
|
||||
this.safeModeDraupnir.sendStartupComplete();
|
||||
}
|
||||
return safeModeResult;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,13 @@ export const DraupnirSafeModeCommand = describeCommand({
|
||||
{ safeModeToggle }: Draupnir,
|
||||
info: BasicInvocationInformation
|
||||
): Promise<Result<SafeModeDraupnir>> {
|
||||
return safeModeToggle.switchToSafeMode({
|
||||
reason: SafeModeReason.ByRequest,
|
||||
user: info.commandSender,
|
||||
});
|
||||
return safeModeToggle.switchToSafeMode(
|
||||
{
|
||||
reason: SafeModeReason.ByRequest,
|
||||
user: info.commandSender,
|
||||
},
|
||||
{ sendStatusOnStart: true }
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -370,3 +370,7 @@ export function renderTableHelp(table: CommandTable): DocumentNode {
|
||||
</fragment>
|
||||
);
|
||||
}
|
||||
|
||||
export function wrapInRoot(node: DocumentNode): DocumentNode {
|
||||
return <root>{node}</root>;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,12 @@ import {
|
||||
ClientRooms,
|
||||
EventReport,
|
||||
RoomEvent,
|
||||
Task,
|
||||
} from "matrix-protection-suite";
|
||||
import { MatrixAdaptorContext } from "../commands/interface-manager/MPSMatrixInterfaceAdaptor";
|
||||
import {
|
||||
MatrixAdaptorContext,
|
||||
sendMatrixEventsFromDeadDocument,
|
||||
} from "../commands/interface-manager/MPSMatrixInterfaceAdaptor";
|
||||
import {
|
||||
StringUserID,
|
||||
StringRoomID,
|
||||
@@ -27,6 +31,12 @@ import {
|
||||
} from "../commands/interface-manager/MatrixPromptForAccept";
|
||||
import { makeCommandDispatcherTimelineListener } from "./ManagementRoom";
|
||||
import { SafeModeToggle } from "./SafeModeToggle";
|
||||
import { Result } from "@gnuxie/typescript-result";
|
||||
import {
|
||||
renderSafeModeStatusInfo,
|
||||
safeModeStatusInfo,
|
||||
} from "./commands/StatusCommand";
|
||||
import { wrapInRoot } from "../commands/interface-manager/MatrixHelpRenderer";
|
||||
|
||||
export class SafeModeDraupnir implements MatrixAdaptorContext {
|
||||
public reactionHandler: MatrixReactionHandler;
|
||||
@@ -90,4 +100,15 @@ export class SafeModeDraupnir implements MatrixAdaptorContext {
|
||||
public stop(): void {
|
||||
this.clientRooms.off("timeline", this.timelineEventListener);
|
||||
}
|
||||
|
||||
public sendStartupComplete(): void {
|
||||
void Task(
|
||||
sendMatrixEventsFromDeadDocument(
|
||||
this.clientPlatform.toRoomMessageSender(),
|
||||
this.commandRoomID,
|
||||
wrapInRoot(renderSafeModeStatusInfo(safeModeStatusInfo(this))),
|
||||
{}
|
||||
) as Promise<Result<void>>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export const SafeModeRestartCommand = describeCommand({
|
||||
async executor({
|
||||
safeModeToggle,
|
||||
}: SafeModeDraupnir): Promise<Result<Draupnir>> {
|
||||
return safeModeToggle.switchToDraupnir();
|
||||
return safeModeToggle.switchToDraupnir({ sendStatusOnStart: true });
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user