From b4080d788d6adbb93c0fa5769313668cecaba50e Mon Sep 17 00:00:00 2001 From: Johann150 Date: Fri, 2 Dec 2022 19:00:58 +0100 Subject: [PATCH] slight refactoring & translating japanese --- .../activitypub/kernel/announce/note.ts | 8 ++--- .../remote/activitypub/kernel/delete/note.ts | 16 +++++----- .../remote/activitypub/kernel/undo/follow.ts | 29 +++++++++---------- .../src/remote/activitypub/resolver.ts | 5 ++++ 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/packages/backend/src/remote/activitypub/kernel/announce/note.ts b/packages/backend/src/remote/activitypub/kernel/announce/note.ts index 527b6b09c..306ce75b1 100644 --- a/packages/backend/src/remote/activitypub/kernel/announce/note.ts +++ b/packages/backend/src/remote/activitypub/kernel/announce/note.ts @@ -18,25 +18,25 @@ export default async function(resolver: Resolver, actor: CacheableRemoteUser, ac return; } - // アナウンス先をブロックしてたら中断 + // Cancel if the announced from host is blocked. const meta = await fetchMeta(); if (meta.blockedHosts.includes(extractDbHost(uri))) return; const unlock = await getApLock(uri); try { - // 既に同じURIを持つものが登録されていないかチェック + // Check if this has already been announced. const exist = await fetchNote(uri); if (exist) { return; } - // Announce対象をresolve + // resolve the announce target let renote; try { renote = await resolveNote(targetUri); } catch (e) { - // 対象が4xxならスキップ + // skip if the target returns a HTTP client error if (e instanceof StatusError) { if (e.isClientError) { apLogger.warn(`Ignored announce target ${targetUri} - ${e.statusCode}`); diff --git a/packages/backend/src/remote/activitypub/kernel/delete/note.ts b/packages/backend/src/remote/activitypub/kernel/delete/note.ts index 9eee00732..8be9153b6 100644 --- a/packages/backend/src/remote/activitypub/kernel/delete/note.ts +++ b/packages/backend/src/remote/activitypub/kernel/delete/note.ts @@ -16,22 +16,22 @@ export default async function(actor: CacheableRemoteUser, uri: string): Promise< if (note == null) { const message = await dbResolver.getMessageFromApId(uri); - if (message == null) return 'message not found'; + if (message == null) return 'skip: message not found'; if (message.userId !== actor.id) { - return '投稿を削除しようとしているユーザーは投稿の作成者ではありません'; + return 'skip: cant delete other actors message'; } await deleteMessage(message); return 'ok: message deleted'; - } + } else { + if (note.userId !== actor.id) { + return 'skip: cant delete other actors note'; + } - if (note.userId !== actor.id) { - return '投稿を削除しようとしているユーザーは投稿の作成者ではありません'; + await deleteNode(actor, note); + return 'ok: note deleted'; } - - await deleteNode(actor, note); - return 'ok: note deleted'; } finally { unlock(); } diff --git a/packages/backend/src/remote/activitypub/kernel/undo/follow.ts b/packages/backend/src/remote/activitypub/kernel/undo/follow.ts index a0bdf0d0b..418eb5255 100644 --- a/packages/backend/src/remote/activitypub/kernel/undo/follow.ts +++ b/packages/backend/src/remote/activitypub/kernel/undo/follow.ts @@ -14,28 +14,27 @@ export default async (actor: CacheableRemoteUser, activity: IFollow): Promise; private user?: ILocalUser;