Skip to content

Commit

Permalink
ForeignLikeOpeMode Resolve #4704
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Jan 5, 2024
1 parent a0c43ea commit 2f2086c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions .config/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ themeColor: '#fb4e4e'

# lazy / ignore
# inboxMassDelOpeMode: lazy
# inboxForeignLikeOpeMode: lazy

# Job late limiter (Default: nolimit, 変更しないことを推奨)
# deliverJobPerSec: 128
Expand Down
1 change: 1 addition & 0 deletions src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export type Source = {
deliverJobMaxAttempts?: number;
inboxJobMaxAttempts?: number;
inboxMassDelOpeMode?: 'lazy' | 'ignore';
inboxForeignLikeOpeMode?: 'lazy' | 'ignore';

mecabSearch?: {
mecabBin?: string;
Expand Down
15 changes: 14 additions & 1 deletion src/server/activitypub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2f2086c

Please sign in to comment.