mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
19 lines
705 B
TypeScript
19 lines
705 B
TypeScript
import { type AppController } from '@/app.ts';
|
|
import { eventsDB } from '@/storages.ts';
|
|
import { paginated, paginationSchema } from '@/utils/api.ts';
|
|
import { renderNotification } from '@/views/mastodon/notifications.ts';
|
|
|
|
const notificationsController: AppController = async (c) => {
|
|
const pubkey = c.get('pubkey')!;
|
|
const { since, until } = paginationSchema.parse(c.req.query());
|
|
|
|
const events = await eventsDB.query(
|
|
[{ kinds: [1], '#p': [pubkey], since, until }],
|
|
{ signal: AbortSignal.timeout(3000) },
|
|
);
|
|
|
|
const statuses = await Promise.all(events.map((event) => renderNotification(event, pubkey)));
|
|
return paginated(c, events, statuses);
|
|
};
|
|
|
|
export { notificationsController };
|