mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
refactor(updateInstanceController): move async function out of callback
This commit is contained in:
parent
33b36ba0ed
commit
d9cc8cc7c2
2 changed files with 5 additions and 4 deletions
|
|
@ -311,10 +311,11 @@ export const updateInstanceController: AppController = async (c) => {
|
|||
return c.json(result.error, 422);
|
||||
}
|
||||
|
||||
const meta = await getInstanceMetadata(await Storages.db(), c.req.raw.signal);
|
||||
|
||||
await updateAdminEvent(
|
||||
{ kinds: [0], authors: [pubkey], limit: 1 },
|
||||
async (_) => {
|
||||
const meta = await getInstanceMetadata(await Storages.db(), c.req.raw.signal);
|
||||
(_) => {
|
||||
const {
|
||||
title,
|
||||
description,
|
||||
|
|
|
|||
|
|
@ -111,12 +111,12 @@ function updateListAdminEvent(
|
|||
/** Fetch existing event, update it, then publish the new admin event. */
|
||||
async function updateAdminEvent<E extends EventStub>(
|
||||
filter: UpdateEventFilter,
|
||||
fn: (prev: NostrEvent | undefined) => E | Promise<E>,
|
||||
fn: (prev: NostrEvent | undefined) => E,
|
||||
c: AppContext,
|
||||
): Promise<NostrEvent> {
|
||||
const store = await Storages.db();
|
||||
const [prev] = await store.query([filter], { limit: 1, signal: c.req.raw.signal });
|
||||
return createAdminEvent(await fn(prev), c);
|
||||
return createAdminEvent(fn(prev), c);
|
||||
}
|
||||
|
||||
function updateUser(pubkey: string, n: Record<string, boolean>, c: AppContext): Promise<NostrEvent> {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue