From 3cacaedb8b7ff1a7919b0d33e58d24b502dfd009 Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Wed, 28 Oct 2026 16:48:18 -0400 Subject: [PATCH] recover olm based on last seen --- server/routers/olm/recoverOlmWithFingerprint.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/server/routers/olm/recoverOlmWithFingerprint.ts b/server/routers/olm/recoverOlmWithFingerprint.ts index d0d8b681d..3e04de480 100644 --- a/server/routers/olm/recoverOlmWithFingerprint.ts +++ b/server/routers/olm/recoverOlmWithFingerprint.ts @@ -1,7 +1,7 @@ import { db, currentFingerprint, olms } from "@server/db"; import logger from "@server/logger"; import HttpCode from "@server/types/HttpCode"; -import { and, eq } from "drizzle-orm"; +import { and, desc, eq } from "drizzle-orm"; import { NextFunction, Request, Response } from "express"; import response from "@server/lib/response"; import createHttpError from "http-errors"; @@ -71,7 +71,8 @@ export async function recoverOlmWithFingerprint( ) ) ) - .orderBy(currentFingerprint.lastSeen); + .orderBy(desc(currentFingerprint.lastSeen)) + .limit(1); if (!result || result.length == 0) { return next( @@ -82,15 +83,6 @@ export async function recoverOlmWithFingerprint( ); } - if (result.length > 1) { - return next( - createHttpError( - HttpCode.CONFLICT, - "multiple matching fingerprints found, not resetting secrets" - ) - ); - } - const [{ olm: foundOlm }] = result; const newSecret = generateId(48);