diff --git a/.config/example.yml b/.config/example.yml index 238aac4e6de4..85317cbff2e6 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -188,6 +188,7 @@ themeColor: '#fb4e4e' # lazy / ignore # inboxMassDelOpeMode: lazy +# inboxForeignLikeOpeMode: lazy # Job late limiter (Default: nolimit, 変更しないことを推奨) # deliverJobPerSec: 128 diff --git a/src/config/types.ts b/src/config/types.ts index a22b378a45e7..a93089dc102a 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -78,6 +78,7 @@ export type Source = { deliverJobMaxAttempts?: number; inboxJobMaxAttempts?: number; inboxMassDelOpeMode?: 'lazy' | 'ignore'; + inboxForeignLikeOpeMode?: 'lazy' | 'ignore'; mecabSearch?: { mecabBin?: string; diff --git a/src/server/activitypub.ts b/src/server/activitypub.ts index f9a9b2746c0d..f457fe7c1f7c 100644 --- a/src/server/activitypub.ts +++ b/src/server/activitypub.ts @@ -28,7 +28,7 @@ import { toUnicode } from 'punycode/'; import Logger from '../services/logger'; import limiter from './api/limiter'; import { IEndpoint } from './api/endpoints'; -import { IActivity } from '../remote/activitypub/type'; +import { IActivity, getApId } from '../remote/activitypub/type'; import { toSingle } from '../prelude/array'; const logger = new Logger('activitypub'); @@ -171,6 +171,19 @@ async function inbox(ctx: Router.RouterContext) { lazy = true; } } + + // ForeignLike + if (toSingle(activity.type) === 'Like') { + const targetHost = new URL(getApId(activity.object)).hostname.toLowerCase(); + if (targetHost !== config.host) { + if (config.inboxForeignLikeOpeMode === 'ignore') { + ctx.status = 202; + return; + } + lazy = true; + } + } + const queue = await (lazy ? processInboxLazy : processInbox)(activity, signature, { ip: ctx.request.ip