Files
pangolin/server/routers/newt/sync.ts
2026-01-12 20:48:18 -08:00

23 lines
770 B
TypeScript

import { Client, Olm } from "@server/db";
import { buildSiteConfigurationForOlmClient } from "./buildSiteConfigurationForOlmClient";
import { sendToClient } from "#dynamic/routers/ws";
import logger from "@server/logger";
export async function sendOlmSyncMessage(olm: Olm, client: Client) {
// NOTE: WE ARE HARDCODING THE RELAY PARAMETER TO FALSE HERE BUT IN THE REGISTER MESSAGE ITS DEFINED BY THE CLIENT
const siteConfigurations = await buildSiteConfigurationForOlmClient(
client,
client.pubKey,
false
);
await sendToClient(olm.olmId, {
type: "olm/sync",
data: {
sites: siteConfigurations
}
}).catch((error) => {
logger.warn(`Error sending olm sync message:`, error);
});
}