diff --git a/packages/backend/.idea/.gitignore b/packages/backend/.idea/.gitignore new file mode 100644 index 000000000..13566b81b --- /dev/null +++ b/packages/backend/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/packages/backend/src/queue/processors/inbox.ts b/packages/backend/src/queue/processors/inbox.ts index 420d74bb0..33949672c 100644 --- a/packages/backend/src/queue/processors/inbox.ts +++ b/packages/backend/src/queue/processors/inbox.ts @@ -20,7 +20,7 @@ import { UserPublickey } from '@/models/entities/user-publickey.js'; const logger = new Logger('inbox'); -// ユーザーのinboxにアクティビティが届いた時の処理 +// Processing when an activity arrives in the user's inbox export default async (job: Bull.Job): Promise => { const signature = job.data.signature; // HTTP-signature const activity = job.data.activity; @@ -30,16 +30,15 @@ export default async (job: Bull.Job): Promise => { delete info['@context']; logger.debug(JSON.stringify(info, null, 2)); //#endregion - const host = toPuny(new URL(signature.keyId).hostname); - // ブロックしてたら中断 + // interrupt if blocked const meta = await fetchMeta(); if (meta.blockedHosts.includes(host)) { return `Blocked request: ${host}`; } - // 非公開モードなら許可なインスタンスのみ + // only whitelisted instances in private mode if (meta.privateMode && !meta.allowedHosts.includes(host)) { return `Blocked request: ${host}`; } @@ -51,7 +50,7 @@ export default async (job: Bull.Job): Promise => { const dbResolver = new DbResolver(); - // HTTP-Signature keyIdを元にDBから取得 + // HTTP-Signature keyId from DB let authUser: { user: CacheableRemoteUser; key: UserPublickey | null; @@ -62,7 +61,7 @@ export default async (job: Bull.Job): Promise => { try { authUser = await dbResolver.getAuthUserFromApId(getApId(activity.actor)); } catch (e) { - // 対象が4xxならスキップ + // Skip if target is 4xx if (e instanceof StatusError) { if (e.isClientError) { return `skip: Ignored deleted actors on both ends ${activity.actor} - ${e.statusCode}`; diff --git a/packages/backend/src/remote/activitypub/type.ts b/packages/backend/src/remote/activitypub/type.ts index 2c4935a87..d04352e4c 100644 --- a/packages/backend/src/remote/activitypub/type.ts +++ b/packages/backend/src/remote/activitypub/type.ts @@ -157,6 +157,7 @@ export interface IActor extends IObject { preferredUsername?: string; manuallyApprovesFollowers?: boolean; movedTo?: string; + alsoKnownAs?: string[]; discoverable?: boolean; inbox: string; sharedInbox?: string; // 後方互換性のため @@ -280,6 +281,10 @@ export interface IFlag extends IActivity { type: 'Flag'; } +export interface IMove extends IActivity { + type: 'Move'; +} + export const isCreate = (object: IObject): object is ICreate => getApType(object) === 'Create'; export const isDelete = (object: IObject): object is IDelete => getApType(object) === 'Delete'; export const isUpdate = (object: IObject): object is IUpdate => getApType(object) === 'Update'; diff --git a/packages/backend/src/server/activitypub.ts b/packages/backend/src/server/activitypub.ts index 250a39bf0..782915756 100644 --- a/packages/backend/src/server/activitypub.ts +++ b/packages/backend/src/server/activitypub.ts @@ -38,6 +38,7 @@ function inbox(ctx: Router.RouterContext) { return; } + // @ts-ignore processInbox(ctx.request.body, signature); ctx.status = 202; @@ -86,7 +87,7 @@ router.get('/notes/:note', async (ctx, next) => { return; } - // リモートだったらリダイレクト + // redirect if remote if (note.userHost != null) { if (note.uri == null || isSelfHost(note.userHost)) { ctx.status = 500;