mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
fix(updateInstanceController): use updateAdminEvent() function
This commit is contained in:
parent
1baab0f868
commit
33b36ba0ed
2 changed files with 4 additions and 4 deletions
|
|
@ -5,7 +5,7 @@ import { AppController } from '@/app.ts';
|
|||
import { Conf } from '@/config.ts';
|
||||
import { addTag } from '@/utils/tags.ts';
|
||||
import { getAuthor } from '@/queries.ts';
|
||||
import { createEvent, paginated, parseBody, updateEvent } from '@/utils/api.ts';
|
||||
import { createEvent, paginated, parseBody, updateAdminEvent } from '@/utils/api.ts';
|
||||
import { getInstanceMetadata } from '@/utils/instance.ts';
|
||||
import { deleteTag } from '@/utils/tags.ts';
|
||||
import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||
|
|
@ -311,7 +311,7 @@ export const updateInstanceController: AppController = async (c) => {
|
|||
return c.json(result.error, 422);
|
||||
}
|
||||
|
||||
await updateEvent(
|
||||
await updateAdminEvent(
|
||||
{ kinds: [0], authors: [pubkey], limit: 1 },
|
||||
async (_) => {
|
||||
const meta = await getInstanceMetadata(await Storages.db(), c.req.raw.signal);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
fn: (prev: NostrEvent | undefined) => E | Promise<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(fn(prev), c);
|
||||
return createAdminEvent(await fn(prev), c);
|
||||
}
|
||||
|
||||
function updateUser(pubkey: string, n: Record<string, boolean>, c: AppContext): Promise<NostrEvent> {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue