mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
25 lines
741 B
TypeScript
25 lines
741 B
TypeScript
import { type AppController } from '@/app.ts';
|
|
import { Storages } from '@/storages.ts';
|
|
import { getTagSet } from '@/tags.ts';
|
|
import { renderStatuses } from '@/views.ts';
|
|
|
|
/** https://docs.joinmastodon.org/methods/bookmarks/#get */
|
|
const bookmarksController: AppController = async (c) => {
|
|
const store = await Storages.db();
|
|
const pubkey = await c.get('signer')?.getPublicKey()!;
|
|
const { signal } = c.req.raw;
|
|
|
|
const [event10003] = await store.query(
|
|
[{ kinds: [10003], authors: [pubkey], limit: 1 }],
|
|
{ signal },
|
|
);
|
|
|
|
if (event10003) {
|
|
const eventIds = getTagSet(event10003.tags, 'e');
|
|
return renderStatuses(c, [...eventIds].reverse());
|
|
} else {
|
|
return c.json([]);
|
|
}
|
|
};
|
|
|
|
export { bookmarksController };
|