mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-23 04:33:50 +01:00
add checks to resolver and performOneActivity
This commit is contained in:
parent
8ff259f573
commit
48f0a83016
@ -18,6 +18,7 @@ import {
|
|||||||
isCollection,
|
isCollection,
|
||||||
isFlag,
|
isFlag,
|
||||||
isMove,
|
isMove,
|
||||||
|
getApId,
|
||||||
} from '../type.js';
|
} from '../type.js';
|
||||||
import { apLogger } from '../logger.js';
|
import { apLogger } from '../logger.js';
|
||||||
import Resolver from '../resolver.js';
|
import Resolver from '../resolver.js';
|
||||||
@ -37,6 +38,8 @@ import block from './block/index.js';
|
|||||||
import flag from './flag/index.js';
|
import flag from './flag/index.js';
|
||||||
import move from './move/index.js';
|
import move from './move/index.js';
|
||||||
import type { IObject } from '../type.js';
|
import type { IObject } from '../type.js';
|
||||||
|
import { extractDbHost } from '@/misc/convert-host.js';
|
||||||
|
import { shouldBlockInstance } from '@/misc/should-block-instance.js';
|
||||||
|
|
||||||
export async function performActivity(actor: CacheableRemoteUser, activity: IObject) {
|
export async function performActivity(actor: CacheableRemoteUser, activity: IObject) {
|
||||||
if (isCollectionOrOrderedCollection(activity)) {
|
if (isCollectionOrOrderedCollection(activity)) {
|
||||||
@ -59,6 +62,12 @@ export async function performActivity(actor: CacheableRemoteUser, activity: IObj
|
|||||||
async function performOneActivity(actor: CacheableRemoteUser, activity: IObject): Promise<void> {
|
async function performOneActivity(actor: CacheableRemoteUser, activity: IObject): Promise<void> {
|
||||||
if (actor.isSuspended) return;
|
if (actor.isSuspended) return;
|
||||||
|
|
||||||
|
if (typeof activity.id !== 'undefined') {
|
||||||
|
const host = extractDbHost(getApId(activity));
|
||||||
|
if (await shouldBlockInstance(host)) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isCreate(activity)) {
|
if (isCreate(activity)) {
|
||||||
await create(actor, activity);
|
await create(actor, activity);
|
||||||
} else if (isDelete(activity)) {
|
} else if (isDelete(activity)) {
|
||||||
|
@ -5,7 +5,7 @@ import { getInstanceActor } from '@/services/instance-actor.js';
|
|||||||
import { fetchMeta } from '@/misc/fetch-meta.js';
|
import { fetchMeta } from '@/misc/fetch-meta.js';
|
||||||
import { extractDbHost, isSelfHost } from '@/misc/convert-host.js';
|
import { extractDbHost, isSelfHost } from '@/misc/convert-host.js';
|
||||||
import { signedGet } from './request.js';
|
import { signedGet } from './request.js';
|
||||||
import { IObject, isCollectionOrOrderedCollection, ICollection, IOrderedCollection } from './type.js';
|
import { IObject, isCollectionOrOrderedCollection, ICollection, IOrderedCollection, getApId } from './type.js';
|
||||||
import { FollowRequests, Notes, NoteReactions, Polls, Users } from '@/models/index.js';
|
import { FollowRequests, Notes, NoteReactions, Polls, Users } from '@/models/index.js';
|
||||||
import { parseUri } from './db-resolver.js';
|
import { parseUri } from './db-resolver.js';
|
||||||
import renderNote from '@/remote/activitypub/renderer/note.js';
|
import renderNote from '@/remote/activitypub/renderer/note.js';
|
||||||
@ -49,6 +49,12 @@ export default class Resolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value !== 'string') {
|
if (typeof value !== 'string') {
|
||||||
|
if (typeof value.id !== 'undefined') {
|
||||||
|
const host = extractDbHost(getApId(value));
|
||||||
|
if (await shouldBlockInstance(host)) {
|
||||||
|
throw new Error('instance is blocked');
|
||||||
|
}
|
||||||
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user