mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-05 17:05:55 +02:00
APリファクタとLD-Signatureの検証に対応 (#6300)
* DbResolver * inbox types * 認証順を変更 * User/Keyあたりをまとめる * LD-Signatue * Validate contexts url * LD-Signature DocumentLoaderにProxyとTimeout
This commit is contained in:
@@ -1,28 +1,22 @@
|
||||
import { IRemoteUser } from '../../../../models/entities/user';
|
||||
import config from '../../../../config';
|
||||
import accept from '../../../../services/following/requests/accept';
|
||||
import { IFollow } from '../../type';
|
||||
import { Users } from '../../../../models';
|
||||
import DbResolver from '../../db-resolver';
|
||||
|
||||
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||
const id = typeof activity.actor === 'string' ? activity.actor : activity.actor.id;
|
||||
if (id == null) throw new Error('missing id');
|
||||
export default async (actor: IRemoteUser, activity: IFollow): Promise<string> => {
|
||||
// ※ activityはこっちから投げたフォローリクエストなので、activity.actorは存在するローカルユーザーである必要がある
|
||||
|
||||
if (!id.startsWith(config.url + '/')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const follower = await Users.findOne({
|
||||
id: id.split('/').pop()
|
||||
});
|
||||
const dbResolver = new DbResolver();
|
||||
const follower = await dbResolver.getUserFromApId(activity.actor);
|
||||
|
||||
if (follower == null) {
|
||||
throw new Error('follower not found');
|
||||
return `skip: follower not found`;
|
||||
}
|
||||
|
||||
if (follower.host != null) {
|
||||
throw new Error('フォローリクエストしたユーザーはローカルユーザーではありません');
|
||||
return `skip: follower is not a local user`;
|
||||
}
|
||||
|
||||
await accept(actor, follower);
|
||||
return `ok`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user