summaryrefslogtreecommitdiff
path: root/src/remote/activitypub/kernel/follow.ts
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2020-05-09 08:21:42 +0900
committerGitHub <noreply@github.com>2020-05-09 08:21:42 +0900
commit070f1f3c6ee3188e1b16236366877c1c243601c1 (patch)
treef77fa43be8524698bc9e46246748a3163dbd4a7a /src/remote/activitypub/kernel/follow.ts
parentWebAuthnでログインできないのを修正 (#6327) (diff)
downloadmisskey-070f1f3c6ee3188e1b16236366877c1c243601c1.tar.gz
misskey-070f1f3c6ee3188e1b16236366877c1c243601c1.tar.bz2
misskey-070f1f3c6ee3188e1b16236366877c1c243601c1.zip
APリファクタとLD-Signatureの検証に対応 (#6300)
* DbResolver * inbox types * 認証順を変更 * User/Keyあたりをまとめる * LD-Signatue * Validate contexts url * LD-Signature DocumentLoaderにProxyとTimeout
Diffstat (limited to 'src/remote/activitypub/kernel/follow.ts')
-rw-r--r--src/remote/activitypub/kernel/follow.ts20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/remote/activitypub/kernel/follow.ts b/src/remote/activitypub/kernel/follow.ts
index fca6d26ccc..3e2063302a 100644
--- a/src/remote/activitypub/kernel/follow.ts
+++ b/src/remote/activitypub/kernel/follow.ts
@@ -1,26 +1,20 @@
import { IRemoteUser } from '../../../models/entities/user';
-import config from '../../../config';
import follow from '../../../services/following/create';
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.object === 'string' ? activity.object : activity.object.id;
- if (id == null) throw new Error('missing id');
-
- if (!id.startsWith(config.url + '/')) {
- return;
- }
-
- const followee = await Users.findOne(id.split('/').pop());
+export default async (actor: IRemoteUser, activity: IFollow): Promise<string> => {
+ const dbResolver = new DbResolver();
+ const followee = await dbResolver.getUserFromApId(activity.object);
if (followee == null) {
- throw new Error('followee not found');
+ return `skip: followee not found`;
}
if (followee.host != null) {
- throw new Error('フォローしようとしているユーザーはローカルユーザーではありません');
+ return `skip: フォローしようとしているユーザーはローカルユーザーではありません`;
}
await follow(actor, followee, activity.id);
+ return `ok`;
};