diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2020-05-09 08:21:42 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-09 08:21:42 +0900 |
| commit | 070f1f3c6ee3188e1b16236366877c1c243601c1 (patch) | |
| tree | f77fa43be8524698bc9e46246748a3163dbd4a7a /src/remote/activitypub/kernel/undo/block.ts | |
| parent | WebAuthnでログインできないのを修正 (#6327) (diff) | |
| download | sharkey-070f1f3c6ee3188e1b16236366877c1c243601c1.tar.gz sharkey-070f1f3c6ee3188e1b16236366877c1c243601c1.tar.bz2 sharkey-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/undo/block.ts')
| -rw-r--r-- | src/remote/activitypub/kernel/undo/block.ts | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/remote/activitypub/kernel/undo/block.ts b/src/remote/activitypub/kernel/undo/block.ts index 17eab0d2d0..73000fc3f1 100644 --- a/src/remote/activitypub/kernel/undo/block.ts +++ b/src/remote/activitypub/kernel/undo/block.ts @@ -1,33 +1,20 @@ -import config from '../../../../config'; import { IBlock } from '../../type'; import unblock from '../../../../services/blocking/delete'; -import { apLogger } from '../../logger'; import { IRemoteUser } from '../../../../models/entities/user'; -import { Users } from '../../../../models'; +import DbResolver from '../../db-resolver'; -const logger = apLogger; - -export default async (actor: IRemoteUser, activity: IBlock): Promise<void> => { - const id = typeof activity.object === 'string' ? activity.object : activity.object.id; - if (id == null) throw new Error('missing id'); - - const uri = activity.id || activity; - - logger.info(`UnBlock: ${uri}`); - - if (!id.startsWith(config.url + '/')) { - return; - } - - const blockee = await Users.findOne(id.split('/').pop()); +export default async (actor: IRemoteUser, activity: IBlock): Promise<string> => { + 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: ブロック解除しようとしているユーザーはローカルユーザーではありません`; } - unblock(actor, blockee); + await unblock(actor, blockee); + return `ok`; }; |