mirror of
https://github.com/fosrl/pangolin.git
synced 2026-10-29 15:09:07 +01:00
recover olm based on last seen
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { db, currentFingerprint, olms } from "@server/db";
|
import { db, currentFingerprint, olms } from "@server/db";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
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 { NextFunction, Request, Response } from "express";
|
||||||
import response from "@server/lib/response";
|
import response from "@server/lib/response";
|
||||||
import createHttpError from "http-errors";
|
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) {
|
if (!result || result.length == 0) {
|
||||||
return next(
|
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 [{ olm: foundOlm }] = result;
|
||||||
|
|
||||||
const newSecret = generateId(48);
|
const newSecret = generateId(48);
|
||||||
|
|||||||
Reference in New Issue
Block a user