mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-17 18:36:37 +00:00
Consolidate the messages into the same enum
This commit is contained in:
@@ -79,7 +79,7 @@ export async function blockClient(
|
||||
|
||||
// Send terminate signal if there's an associated OLM and it's connected
|
||||
if (client.olmId && client.online) {
|
||||
await sendTerminateClient(client.clientId, OlmErrorCodes.TERMINATED_BLOCKED, "Blocked", client.olmId);
|
||||
await sendTerminateClient(client.clientId, OlmErrorCodes.TERMINATED_BLOCKED, client.olmId);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ export async function deleteClient(
|
||||
await rebuildClientAssociationsFromClient(deletedClient, trx);
|
||||
|
||||
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
|
||||
await sendTerminateClient(deletedClient.clientId, OlmErrorCodes.TERMINATED_DELETED, olm.olmId); // the olmId needs to be provided because it cant look it up after deletion
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@ import { OlmErrorCodes } from "../olm/error";
|
||||
|
||||
export async function sendTerminateClient(
|
||||
clientId: number,
|
||||
code: (typeof OlmErrorCodes)[keyof typeof OlmErrorCodes],
|
||||
message: string,
|
||||
error: (typeof OlmErrorCodes)[keyof typeof OlmErrorCodes],
|
||||
olmId?: string | null
|
||||
) {
|
||||
if (!olmId) {
|
||||
@@ -24,8 +23,8 @@ export async function sendTerminateClient(
|
||||
await sendToClient(olmId, {
|
||||
type: `olm/terminate`,
|
||||
data: {
|
||||
code,
|
||||
message
|
||||
code: error.code,
|
||||
message: error.message
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user