diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2018-09-01 21:38:49 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-01 21:38:49 +0900 |
| commit | 4b1886990f7de0a1b993b2f3f17c3ee99f78a5ec (patch) | |
| tree | 15426a39bf9b6d30c1ddb50a61e070d5bda6300a /src/queue/processors | |
| parent | 8.20.0 (diff) | |
| parent | Send Update activity (diff) | |
| download | sharkey-4b1886990f7de0a1b993b2f3f17c3ee99f78a5ec.tar.gz sharkey-4b1886990f7de0a1b993b2f3f17c3ee99f78a5ec.tar.bz2 sharkey-4b1886990f7de0a1b993b2f3f17c3ee99f78a5ec.zip | |
Merge pull request #2570 from mei23/mei-0901-update2b
Implement ActivityPub Update(Person)
Diffstat (limited to 'src/queue/processors')
| -rw-r--r-- | src/queue/processors/http/process-inbox.ts | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/queue/processors/http/process-inbox.ts b/src/queue/processors/http/process-inbox.ts index 7e564dd32a..8e6b3769de 100644 --- a/src/queue/processors/http/process-inbox.ts +++ b/src/queue/processors/http/process-inbox.ts @@ -5,7 +5,7 @@ const httpSignature = require('http-signature'); import parseAcct from '../../../misc/acct/parse'; import User, { IRemoteUser } from '../../../models/user'; import perform from '../../../remote/activitypub/perform'; -import { resolvePerson } from '../../../remote/activitypub/models/person'; +import { resolvePerson, updatePerson } from '../../../remote/activitypub/models/person'; import { toUnicode } from 'punycode'; import { URL } from 'url'; @@ -44,11 +44,6 @@ export default async (job: bq.Job, done: any): Promise<void> => { } user = await User.findOne({ usernameLower: username, host: host.toLowerCase() }) as IRemoteUser; - - // アクティビティを送信してきたユーザーがまだMisskeyサーバーに登録されていなかったら登録する - if (user === null) { - user = await resolvePerson(activity.actor) as IRemoteUser; - } } else { // アクティビティ内のホストの検証 const host = toUnicode(new URL(signature.keyId).hostname.toLowerCase()); @@ -64,11 +59,26 @@ export default async (job: bq.Job, done: any): Promise<void> => { host: { $ne: null }, 'publicKey.id': signature.keyId }) as IRemoteUser; + } - // アクティビティを送信してきたユーザーがまだMisskeyサーバーに登録されていなかったら登録する - if (user === null) { - user = await resolvePerson(activity.actor) as IRemoteUser; + // Update activityの場合は、ここで署名検証/更新処理まで実施して終了 + if (activity.type === 'Update') { + if (activity.object && activity.object.type === 'Person') { + if (user == null) { + console.warn('Update activity received, but user not registed.'); + } else if (!httpSignature.verifySignature(signature, user.publicKey.publicKeyPem)) { + console.warn('Update activity received, but signature verification failed.'); + } else { + updatePerson(activity.actor, null, activity.object); + } } + done(); + return; + } + + // アクティビティを送信してきたユーザーがまだMisskeyサーバーに登録されていなかったら登録する + if (user === null) { + user = await resolvePerson(activity.actor) as IRemoteUser; } if (user === null) { |