forked from FoundKeyGang/FoundKey
Hélène
b600efae0d
Enforces HTTP signatures on object fetches, and rejects fetches from blocked instances. This should mean proper and full blocking of remote instances. This is now default behavior, which makes it a breaking change. To disable it (mostly for development purposes), the configuration item `allowUnsignedFetches` can be set to true. It is not the default for development environments as it is important to have as close as possible behavior to real environments for ActivityPub development. Co-authored-by: nullobsi <me@nullob.si> Co-authored-by: Norm <normandy@biribiri.dev> Changelog: Added
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import Router from '@koa/router';
|
|
import { IsNull } from 'typeorm';
|
|
import config from '@/config/index.js';
|
|
import { renderActivity } from '@/remote/activitypub/renderer/index.js';
|
|
import renderOrderedCollection from '@/remote/activitypub/renderer/ordered-collection.js';
|
|
import renderNote from '@/remote/activitypub/renderer/note.js';
|
|
import { Users, Notes, UserNotePinings } from '@/models/index.js';
|
|
import { setResponseType } from '../activitypub.js';
|
|
|
|
export default async (ctx: Router.RouterContext) => {
|
|
const userId = ctx.params.user;
|
|
|
|
const user = await Users.findOneBy({
|
|
id: userId,
|
|
host: IsNull(),
|
|
});
|
|
|
|
if (user == null) {
|
|
ctx.status = 404;
|
|
return;
|
|
}
|
|
|
|
const pinings = await UserNotePinings.find({
|
|
where: { userId: user.id },
|
|
order: { id: 'DESC' },
|
|
});
|
|
|
|
const pinnedNotes = await Promise.all(pinings.map(pining =>
|
|
Notes.findOneByOrFail({ id: pining.noteId })));
|
|
|
|
const renderedNotes = await Promise.all(pinnedNotes.map(note => renderNote(note)));
|
|
|
|
const rendered = renderOrderedCollection(
|
|
`${config.url}/users/${userId}/collections/featured`,
|
|
renderedNotes.length, undefined, undefined, renderedNotes,
|
|
);
|
|
|
|
ctx.body = renderActivity(rendered);
|
|
setResponseType(ctx);
|
|
};
|