Reorder setting the olm agent and version

This commit is contained in:
Owen
2026-01-19 16:30:34 -08:00
parent 35cfd6bec9
commit 6765d5ad26

View File

@@ -69,21 +69,36 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
platformFingerprint: fingerprint.platformFingerprint platformFingerprint: fingerprint.platformFingerprint
}); });
} else { } else {
await db const hasChanges =
.update(fingerprints) existingFingerprint.username !== fingerprint.username ||
.set({ existingFingerprint.hostname !== fingerprint.hostname ||
lastSeen: now, existingFingerprint.platform !== fingerprint.platform ||
username: fingerprint.username, existingFingerprint.osVersion !== fingerprint.osVersion ||
hostname: fingerprint.hostname, existingFingerprint.kernelVersion !==
platform: fingerprint.platform, fingerprint.kernelVersion ||
osVersion: fingerprint.osVersion, existingFingerprint.arch !== fingerprint.arch ||
kernelVersion: fingerprint.kernelVersion, existingFingerprint.deviceModel !== fingerprint.deviceModel ||
arch: fingerprint.arch, existingFingerprint.serialNumber !== fingerprint.serialNumber ||
deviceModel: fingerprint.deviceModel, existingFingerprint.platformFingerprint !==
serialNumber: fingerprint.serialNumber, fingerprint.platformFingerprint;
platformFingerprint: fingerprint.platformFingerprint
}) if (hasChanges) {
.where(eq(fingerprints.olmId, olm.olmId)); await db
.update(fingerprints)
.set({
lastSeen: now,
username: fingerprint.username,
hostname: fingerprint.hostname,
platform: fingerprint.platform,
osVersion: fingerprint.osVersion,
kernelVersion: fingerprint.kernelVersion,
arch: fingerprint.arch,
deviceModel: fingerprint.deviceModel,
serialNumber: fingerprint.serialNumber,
platformFingerprint: fingerprint.platformFingerprint
})
.where(eq(fingerprints.olmId, olm.olmId));
}
} }
} }
@@ -110,6 +125,21 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
}); });
} }
if (
(olmVersion && olm.version !== olmVersion) ||
(olmAgent && olm.agent !== olmAgent) ||
olm.archived
) {
await db
.update(olms)
.set({
version: olmVersion,
agent: olmAgent,
archived: false
})
.where(eq(olms.olmId, olm.olmId));
}
const [client] = await db const [client] = await db
.select() .select()
.from(clients) .from(clients)
@@ -237,21 +267,6 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
return; return;
} }
if (
(olmVersion && olm.version !== olmVersion) ||
(olmAgent && olm.agent !== olmAgent) ||
olm.archived
) {
await db
.update(olms)
.set({
version: olmVersion,
agent: olmAgent,
archived: false
})
.where(eq(olms.olmId, olm.olmId));
}
if (client.pubKey !== publicKey || client.archived) { if (client.pubKey !== publicKey || client.archived) {
logger.info( logger.info(
"Public key mismatch. Updating public key and clearing session info..." "Public key mismatch. Updating public key and clearing session info..."