mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-04 22:24:25 +01:00
Add favourited_by and reblogged_by controllers
This commit is contained in:
@@ -30,6 +30,15 @@ const instanceController: AppController = (c) => {
|
||||
max_media_attachments: 20,
|
||||
},
|
||||
},
|
||||
pleroma: {
|
||||
metadata: {
|
||||
features: [
|
||||
'mastodon_api',
|
||||
'mastodon_api_streaming',
|
||||
'exposable_reactions',
|
||||
],
|
||||
},
|
||||
},
|
||||
languages: ['en'],
|
||||
stats: {
|
||||
domain_count: 0,
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { type AppController } from '@/app.ts';
|
||||
import { type Event, ISO6391, z } from '@/deps.ts';
|
||||
import { getAncestors, getDescendants, getEvent } from '@/queries.ts';
|
||||
import { toStatus } from '@/transformers/nostr-to-mastoapi.ts';
|
||||
import { createEvent, parseBody } from '@/utils/web.ts';
|
||||
import * as mixer from '@/mixer.ts';
|
||||
import { getAncestors, getAuthor, getDescendants, getEvent } from '@/queries.ts';
|
||||
import { toAccount, toStatus } from '@/transformers/nostr-to-mastoapi.ts';
|
||||
import { createEvent, paginated, parseBody } from '@/utils/web.ts';
|
||||
|
||||
const createStatusSchema = z.object({
|
||||
in_reply_to_id: z.string().regex(/[0-9a-f]{64}/).nullish(),
|
||||
@@ -128,4 +129,41 @@ const favouriteController: AppController = async (c) => {
|
||||
}
|
||||
};
|
||||
|
||||
export { contextController, createStatusController, favouriteController, statusController };
|
||||
const favouritedByController: AppController = async (c) => {
|
||||
const id = c.req.param('id');
|
||||
|
||||
const events = await mixer.getFilters([{ kinds: [7], '#e': [id] }]);
|
||||
|
||||
const accounts = await Promise.all(events.map(async ({ pubkey }) => {
|
||||
const author = await getAuthor(pubkey);
|
||||
if (author) {
|
||||
return toAccount(author);
|
||||
}
|
||||
}));
|
||||
|
||||
return paginated(c, events, accounts);
|
||||
};
|
||||
|
||||
const rebloggedByController: AppController = async (c) => {
|
||||
const id = c.req.param('id');
|
||||
|
||||
const events = await mixer.getFilters([{ kinds: [6], '#e': [id] }]);
|
||||
|
||||
const accounts = await Promise.all(events.map(async ({ pubkey }) => {
|
||||
const author = await getAuthor(pubkey);
|
||||
if (author) {
|
||||
return toAccount(author);
|
||||
}
|
||||
}));
|
||||
|
||||
return paginated(c, events, accounts);
|
||||
};
|
||||
|
||||
export {
|
||||
contextController,
|
||||
createStatusController,
|
||||
favouriteController,
|
||||
favouritedByController,
|
||||
rebloggedByController,
|
||||
statusController,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user