Fix search timing out on non-existing nostrKey

fixes #1
This commit is contained in:
Râu Cao 2024-10-23 22:38:30 +02:00
parent 062ded9e6d
commit 32f39685a1
Signed by: raucao
GPG Key ID: 37036C356E56CC51
2 changed files with 10 additions and 3 deletions

11
ldap.ts
View File

@ -19,7 +19,12 @@ export async function lookupPubkeyByUsername(username: string) {
attributes: ["nostrKey"],
});
pubkey = searchEntries[0]?.nostrKey as string;
if (
searchEntries.length > 0 &&
typeof searchEntries[0].nostrKey === "string"
) {
pubkey = searchEntries[0].nostrKey;
}
} catch (e) {
console.error(e);
} finally {
@ -40,7 +45,9 @@ export async function lookupUsernameByPubkey(pubkey: string) {
attributes: ["cn"],
});
username = searchEntries[0]?.cn;
if (searchEntries.length > 0) {
username = searchEntries[0].cn;
}
} catch (e) {
console.error(e);
} finally {

View File

@ -4,7 +4,7 @@ import { cleanContentHtml } from "../feeds.ts";
describe("Feeds", () => {
describe("#cleanContentHtml", () => {
let articleHtml = Deno.readTextFileSync(
const articleHtml = Deno.readTextFileSync(
"tests/fixtures/gfm-content-1.html",
);