fix(activity-pub): アカウント削除アクティビティが配送されないことがある問題を修正

Fix #7506
This commit is contained in:
syuilo 2021-08-13 21:43:48 +09:00
parent 5f86509abc
commit a6cfb5a7db
4 changed files with 14 additions and 7 deletions

View File

@ -13,6 +13,7 @@
- Misskey更新時にダイアログを表示するように
### Bugfixes
- ActivityPub: アカウント削除アクティビティが配送されないことがある問題を修正
## 12.87.0 (2021/08/12)

View File

@ -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
};

View File

@ -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 */

View File

@ -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<void>((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']
});