diff --git a/CHANGELOG.md b/CHANGELOG.md index da90a5c07..ce2449e38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Misskey更新時にダイアログを表示するように ### Bugfixes +- ActivityPub: アカウント削除アクティビティが配送されないことがある問題を修正 ## 12.87.0 (2021/08/12) diff --git a/src/queue/index.ts b/src/queue/index.ts index c7b7f0392..dda0c2852 100644 --- a/src/queue/index.ts +++ b/src/queue/index.ts @@ -13,6 +13,7 @@ import { getJobInfo } from './get-job-info'; import { dbQueue, deliverQueue, inboxQueue, objectStorageQueue } from './queues'; import { ThinUser } from './types'; import { IActivity } from '@/remote/activitypub/type'; +import { getUserKeypair } from '@/misc/keypair-store'; function renderError(e: Error): any { return { @@ -59,12 +60,17 @@ objectStorageQueue .on('error', (job: any, err: Error) => objectStorageLogger.error(`error ${err}`, { job, e: renderError(err) })) .on('stalled', (job) => objectStorageLogger.warn(`stalled id=${job.id}`)); -export function deliver(user: ThinUser, content: unknown, to: string | null) { +export async function deliver(user: ThinUser, content: unknown, to: string | null) { if (content == null) return null; if (to == null) return null; + const keypair = await getUserKeypair(user.id); + const data = { - user, + user: { + ...user, + privateKey: keypair.privateKey, + }, content, to }; diff --git a/src/queue/types.ts b/src/queue/types.ts index a782fc6b9..6ebfb765f 100644 --- a/src/queue/types.ts +++ b/src/queue/types.ts @@ -5,7 +5,9 @@ import * as httpSignature from 'http-signature'; export type DeliverJobData = { /** Actor */ - user: ThinUser; + user: ThinUser & { + privateKey: string; + }; /** Activity */ content: unknown; /** inbox URL to deliver */ diff --git a/src/remote/activitypub/request.ts b/src/remote/activitypub/request.ts index e4dca3232..459d5f6ac 100644 --- a/src/remote/activitypub/request.ts +++ b/src/remote/activitypub/request.ts @@ -11,7 +11,7 @@ import got from 'got'; import * as Got from 'got'; import { getUserKeypair } from '@/misc/keypair-store'; -export default async (user: { id: User['id'] }, url: string, object: any) => { +export default async (user: { id: User['id']; privateKey: string; }, url: string, object: any) => { const timeout = 10 * 1000; const { protocol, hostname, port, pathname, search } = new URL(url); @@ -22,8 +22,6 @@ export default async (user: { id: User['id'] }, url: string, object: any) => { sha256.update(data); const hash = sha256.digest('base64'); - const keypair = await getUserKeypair(user.id); - await new Promise((resolve, reject) => { const req = https.request({ agent: getAgentByUrl(new URL(`https://example.net`)), @@ -48,7 +46,7 @@ export default async (user: { id: User['id'] }, url: string, object: any) => { sign(req, { authorizationHeaderName: 'Signature', - key: keypair.privateKey, + key: user.privateKey, keyId: `${config.url}/users/${user.id}#main-key`, headers: ['(request-target)', 'date', 'host', 'digest'] });