mirror of
https://github.com/aljazceru/ditto.git
synced 2025-12-17 05:24:22 +01:00
refactor(updateInstanceController): move async function out of callback
This commit is contained in:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user