mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-07 15:44:22 +01:00
feat: repost functionality
This commit is contained in:
@@ -7,7 +7,7 @@ import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
||||
import { addTag, deleteTag } from '@/tags.ts';
|
||||
import { createEvent, paginationSchema, parseBody, updateListEvent } from '@/utils/api.ts';
|
||||
import { renderEventAccounts } from '@/views.ts';
|
||||
import { renderStatus } from '@/views/mastodon/statuses.ts';
|
||||
import { renderReblog, renderStatus } from '@/views/mastodon/statuses.ts';
|
||||
import { getLnurl } from '@/utils/lnurl.ts';
|
||||
|
||||
const createStatusSchema = z.object({
|
||||
@@ -173,6 +173,31 @@ const favouritedByController: AppController = (c) => {
|
||||
return renderEventAccounts(c, [{ kinds: [7], '#e': [id], ...params }]);
|
||||
};
|
||||
|
||||
/** https://docs.joinmastodon.org/methods/statuses/#boost */
|
||||
const reblogStatusController: AppController = async (c) => {
|
||||
const eventId = c.req.param('id');
|
||||
|
||||
const event = await getEvent(eventId, {
|
||||
kind: 1,
|
||||
});
|
||||
|
||||
if (event == undefined) {
|
||||
return c.json({ error: 'Event not found.' }, 404);
|
||||
}
|
||||
|
||||
const tags: string[][] = [['e', event.id], ['p', event.pubkey]];
|
||||
|
||||
const reblogEvent = await createEvent({
|
||||
kind: 6,
|
||||
content: JSON.stringify(event),
|
||||
tags,
|
||||
}, c);
|
||||
|
||||
const status = await renderReblog(reblogEvent, reblogEvent.pubkey);
|
||||
|
||||
return c.json(status);
|
||||
};
|
||||
|
||||
const rebloggedByController: AppController = (c) => {
|
||||
const id = c.req.param('id');
|
||||
const params = paginationSchema.parse(c.req.query());
|
||||
@@ -339,6 +364,7 @@ export {
|
||||
favouriteController,
|
||||
favouritedByController,
|
||||
pinController,
|
||||
reblogStatusController,
|
||||
rebloggedByController,
|
||||
statusController,
|
||||
unbookmarkController,
|
||||
|
||||
Reference in New Issue
Block a user