mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-03 05:36:16 +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,32 +1,22 @@
|
||||
import config from '../../../../config';
|
||||
import { IBlock, getApId } from '../../type';
|
||||
import { IBlock } from '../../type';
|
||||
import block from '../../../../services/blocking/create';
|
||||
import { apLogger } from '../../logger';
|
||||
import { Users } from '../../../../models';
|
||||
import { IRemoteUser } from '../../../../models/entities/user';
|
||||
import DbResolver from '../../db-resolver';
|
||||
|
||||
const logger = apLogger;
|
||||
export default async (actor: IRemoteUser, activity: IBlock): Promise<string> => {
|
||||
// ※ activity.objectにブロック対象があり、それは存在するローカルユーザーのはず
|
||||
|
||||
export default async (actor: IRemoteUser, activity: IBlock): Promise<void> => {
|
||||
const id = getApId(activity.object);
|
||||
|
||||
const uri = getApId(activity);
|
||||
|
||||
logger.info(`Block: ${uri}`);
|
||||
|
||||
if (!id.startsWith(config.url + '/')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const blockee = await Users.findOne(id.split('/').pop());
|
||||
const dbResolver = new DbResolver();
|
||||
const blockee = await dbResolver.getUserFromApId(activity.object);
|
||||
|
||||
if (blockee == null) {
|
||||
throw new Error('blockee not found');
|
||||
return `skip: blockee not found`;
|
||||
}
|
||||
|
||||
if (blockee.host != null) {
|
||||
throw new Error('ブロックしようとしているユーザーはローカルユーザーではありません');
|
||||
return `skip: ブロックしようとしているユーザーはローカルユーザーではありません`;
|
||||
}
|
||||
|
||||
block(actor, blockee);
|
||||
await block(actor, blockee);
|
||||
return `ok`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user