forked from FoundKeyGang/FoundKey
Johann150
1516ddfc9b
The CacheableUser, CacheableLocalUser and CacheableRemoteUser are identical types to User, ILocalUser and IRemoteUser so it seems nonsensical to have different types for them.
31 lines
942 B
TypeScript
31 lines
942 B
TypeScript
import { IRemoteUser } from '@/models/entities/user.js';
|
|
import { remoteReject } from '@/services/following/reject.js';
|
|
import { relayRejected } from '@/services/relay.js';
|
|
import { Users } from '@/models/index.js';
|
|
import { IFollow } from '../../type.js';
|
|
import { DbResolver } from '../../db-resolver.js';
|
|
|
|
export default async (actor: IRemoteUser, activity: IFollow): Promise<string> => {
|
|
// activity is a follow request started by this server, so activity.actor must be an existing local user.
|
|
|
|
const dbResolver = new DbResolver();
|
|
const follower = await dbResolver.getUserFromApId(activity.actor);
|
|
|
|
if (follower == null) {
|
|
return 'skip: follower not found';
|
|
}
|
|
|
|
if (!Users.isLocalUser(follower)) {
|
|
return 'skip: follower is not a local user';
|
|
}
|
|
|
|
// relay
|
|
const match = activity.id?.match(/follow-relay\/(\w+)/);
|
|
if (match) {
|
|
return await relayRejected(match[1]);
|
|
}
|
|
|
|
await remoteReject(actor, follower);
|
|
return 'ok';
|
|
};
|