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
24 lines
667 B
TypeScript
24 lines
667 B
TypeScript
import { IsNull } from 'typeorm';
|
|
import { ILocalUser, User } from '@/models/entities/user.js';
|
|
import { Users } from '@/models/index.js';
|
|
import { getSystemUser } from './system-user.js';
|
|
|
|
const ACTOR_USERNAME = 'instance.actor' as const;
|
|
|
|
let instanceActor = await Users.findOneBy({
|
|
host: IsNull(),
|
|
username: ACTOR_USERNAME,
|
|
}) as ILocalUser | undefined;
|
|
|
|
export async function getInstanceActor(): Promise<ILocalUser> {
|
|
if (!instanceActor) {
|
|
instanceActor = await getSystemUser(ACTOR_USERNAME) as ILocalUser;
|
|
}
|
|
|
|
return instanceActor;
|
|
}
|
|
|
|
export function isInstanceActor(user: User): boolean {
|
|
return user.username === ACTOR_USERNAME && user.host === null;
|
|
}
|