mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-28 15:56:39 +00:00
Send terminate error messages
This commit is contained in:
@@ -10,6 +10,7 @@ import { fromError } from "zod-validation-error";
|
||||
import logger from "@server/logger";
|
||||
import { rebuildClientAssociationsFromClient } from "@server/lib/rebuildClientAssociations";
|
||||
import { sendTerminateClient } from "../client/terminate";
|
||||
import { OlmErrorCodes } from "./error";
|
||||
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
@@ -52,7 +53,7 @@ export async function archiveUserOlm(
|
||||
.where(eq(clients.clientId, client.clientId));
|
||||
|
||||
await rebuildClientAssociationsFromClient(client, trx);
|
||||
await sendTerminateClient(client.clientId, olmId);
|
||||
await sendTerminateClient(client.clientId, OlmErrorCodes.TERMINATED_ARCHIVED, "Archived", olmId);
|
||||
}
|
||||
|
||||
// Archive the OLM (set archived to true)
|
||||
|
||||
@@ -11,6 +11,7 @@ import logger from "@server/logger";
|
||||
import { OpenAPITags, registry } from "@server/openApi";
|
||||
import { rebuildClientAssociationsFromClient } from "@server/lib/rebuildClientAssociations";
|
||||
import { sendTerminateClient } from "../client/terminate";
|
||||
import { OlmErrorCodes } from "./error";
|
||||
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
@@ -76,6 +77,8 @@ export async function deleteUserOlm(
|
||||
if (olm) {
|
||||
await sendTerminateClient(
|
||||
deletedClient.clientId,
|
||||
OlmErrorCodes.TERMINATED_DELETED,
|
||||
"Deleted",
|
||||
olm.olmId
|
||||
); // the olmId needs to be provided because it cant look it up after deletion
|
||||
}
|
||||
|
||||
@@ -10,7 +10,13 @@ export const OlmErrorCodes = {
|
||||
USER_ID_NOT_FOUND: "USER_ID_NOT_FOUND",
|
||||
INVALID_USER_SESSION: "INVALID_USER_SESSION",
|
||||
USER_ID_MISMATCH: "USER_ID_MISMATCH",
|
||||
ACCESS_POLICY_DENIED: "ACCESS_POLICY_DENIED"
|
||||
ACCESS_POLICY_DENIED: "ACCESS_POLICY_DENIED",
|
||||
TERMINATED_REKEYED: "TERMINATED_REKEYED",
|
||||
TERMINATED_ORG_DELETED: "TERMINATED_ORG_DELETED",
|
||||
TERMINATED_INACTIVITY: "TERMINATED_INACTIVITY",
|
||||
TERMINATED_DELETED: "TERMINATED_DELETED",
|
||||
TERMINATED_ARCHIVED: "TERMINATED_ARCHIVED",
|
||||
TERMINATED_BLOCKED: "TERMINATED_BLOCKED"
|
||||
} as const;
|
||||
|
||||
// Helper function to send registration error
|
||||
|
||||
@@ -10,6 +10,7 @@ import { sendTerminateClient } from "../client/terminate";
|
||||
import { encodeHexLowerCase } from "@oslojs/encoding";
|
||||
import { sha256 } from "@oslojs/crypto/sha2";
|
||||
import { sendOlmSyncMessage } from "./sync";
|
||||
import { OlmErrorCodes } from "./error";
|
||||
|
||||
// Track if the offline checker interval is running
|
||||
let offlineCheckerInterval: NodeJS.Timeout | null = null;
|
||||
@@ -64,6 +65,8 @@ export const startOlmOfflineChecker = (): void => {
|
||||
try {
|
||||
await sendTerminateClient(
|
||||
offlineClient.clientId,
|
||||
OlmErrorCodes.TERMINATED_INACTIVITY,
|
||||
"Client terminated due to inactivity",
|
||||
offlineClient.olmId
|
||||
); // terminate first
|
||||
// wait a moment to ensure the message is sent
|
||||
|
||||
Reference in New Issue
Block a user