Some checks failed
CI / Test and lint (push) Failing after 10m22s
Fixes a bunch of problems with how Nostr links are created and replaced in Markdown content
35 lines
874 B
TypeScript
35 lines
874 B
TypeScript
// deno-lint-ignore-file require-await
|
|
import config from "./config.ts";
|
|
import { lookupUsernameByPubkey as ldapLookupUsername } from "./ldap.ts";
|
|
import { lookupPubkeyByUsername as ldapLookupPubkey } from "./ldap.ts";
|
|
|
|
export async function lookupUsernameByPubkey(pubkey: string): Promise<string | undefined> {
|
|
let username;
|
|
for (const [key, value] of Object.entries(config.staticUsers)) {
|
|
if (value === pubkey) {
|
|
username = key;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (username) {
|
|
return username;
|
|
} else {
|
|
if (config.ldapEnabled) {
|
|
return ldapLookupUsername(pubkey);
|
|
}
|
|
}
|
|
}
|
|
|
|
export async function lookupPubkeyByUsername(username: string): Promise<string | undefined> {
|
|
const pubkey = config.staticUsers[username];
|
|
|
|
if (pubkey) {
|
|
return pubkey;
|
|
} else {
|
|
if (config.ldapEnabled) {
|
|
return ldapLookupPubkey(username);
|
|
}
|
|
}
|
|
}
|