diff options
| author | mei23 <m@m544.net> | 2018-09-01 17:53:38 +0900 |
|---|---|---|
| committer | mei23 <m@m544.net> | 2018-09-01 20:23:01 +0900 |
| commit | 3efffbcf22f9292bfe4644df4b7627687a6748f5 (patch) | |
| tree | b72396d064a4a732026cbcfcabb32582ab50821e /src/queue/processors/http | |
| parent | updatePersonで再割り当てを考慮する (diff) | |
| download | sharkey-3efffbcf22f9292bfe4644df4b7627687a6748f5.tar.gz sharkey-3efffbcf22f9292bfe4644df4b7627687a6748f5.tar.bz2 sharkey-3efffbcf22f9292bfe4644df4b7627687a6748f5.zip | |
Receive Update activity
Diffstat (limited to 'src/queue/processors/http')
| -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) { |