mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-03 06:46:10 +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,26 +1,20 @@
|
||||
import config from '../../../../config';
|
||||
import unfollow from '../../../../services/following/delete';
|
||||
import cancelRequest from '../../../../services/following/requests/cancel';
|
||||
import { IFollow } from '../../type';
|
||||
import { IRemoteUser } from '../../../../models/entities/user';
|
||||
import { Users, FollowRequests, Followings } from '../../../../models';
|
||||
import { FollowRequests, Followings } 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: フォロー解除しようとしているユーザーはローカルユーザーではありません`;
|
||||
}
|
||||
|
||||
const req = await FollowRequests.findOne({
|
||||
@@ -35,9 +29,13 @@ export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||
|
||||
if (req) {
|
||||
await cancelRequest(followee, actor);
|
||||
return `ok: follow request canceled`;
|
||||
}
|
||||
|
||||
if (following) {
|
||||
await unfollow(actor, followee);
|
||||
return `ok: unfollowed`;
|
||||
}
|
||||
|
||||
return `skip: リクエストもフォローもされていない`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user