Consolidate the messages into the same enum

This commit is contained in:
Owen
2026-01-17 11:41:10 -08:00
parent 888f5f8bb6
commit ce632a25cf
11 changed files with 85 additions and 54 deletions

View File

@@ -25,6 +25,7 @@ import { OpenAPITags, registry } from "@server/openApi";
import { hashPassword } from "@server/auth/password";
import { disconnectClient, sendToClient } from "#private/routers/ws";
import { OlmErrorCodes, sendOlmError } from "@server/routers/olm/error";
import { sendTerminateClient } from "@server/routers/client/terminate";
const reGenerateSecretParamsSchema = z.strictObject({
clientId: z.string().transform(Number).pipe(z.int().positive())
@@ -118,15 +119,12 @@ export async function reGenerateClientSecret(
// Only disconnect if explicitly requested
if (disconnect) {
const payload = {
type: `olm/terminate`,
data: {
code: OlmErrorCodes.TERMINATED_REKEYED,
message: "Client secret has been regenerated"
}
};
// Don't await this to prevent blocking the response
sendToClient(existingOlms[0].olmId, payload).catch((error) => {
sendTerminateClient(
clientId,
OlmErrorCodes.TERMINATED_REKEYED,
existingOlms[0].olmId
).catch((error) => {
logger.error(
"Failed to send termination message to olm:",
error