X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Factivitypub.ts;h=2a2d86a24ffa56553759e9b5cce6ee945ac90ac2;hb=7e0f50d6e0c7dc583d40e196c283eb20dc386ae6;hp=6cd23f230016df1cc263a4fcb00cdd2a7ec06312;hpb=76148b27f7501bac061992136852be4303370c8d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts index 6cd23f230..2a2d86a24 100644 --- a/server/middlewares/activitypub.ts +++ b/server/middlewares/activitypub.ts @@ -1,13 +1,11 @@ import { NextFunction, Request, Response } from 'express' -import { ActivityDelete, ActivityPubSignature } from '../../shared' +import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor' +import { getAPId } from '@server/lib/activitypub/activity' +import { ActivityDelete, ActivityPubSignature, HttpStatusCode } from '@shared/models' import { logger } from '../helpers/logger' import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto' import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants' -import { getOrCreateActorAndServerAndModel } from '../lib/activitypub/actor' -import { loadActorUrlOrGetFromWebfinger } from '../helpers/webfinger' -import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor' -import { getAPId } from '@server/helpers/activitypub' -import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' +import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../lib/activitypub/actors' async function checkSignature (req: Request, res: Response, next: NextFunction) { try { @@ -100,7 +98,7 @@ async function checkHttpSignature (req: Request, res: Response) { actorUrl = await loadActorUrlOrGetFromWebfinger(actorUrl.replace(/^acct:/, '')) } - const actor = await getOrCreateActorAndServerAndModel(actorUrl) + const actor = await getOrCreateAPActor(actorUrl) const verified = isHTTPSignatureVerified(parsed, actor) if (verified !== true) { @@ -135,7 +133,7 @@ async function checkJsonLDSignature (req: Request, res: Response) { logger.debug('Checking JsonLD signature of actor %s...', creator) - const actor = await getOrCreateActorAndServerAndModel(creator) + const actor = await getOrCreateAPActor(creator) const verified = await isJsonLDSignatureVerified(actor, req.body) if (verified !== true) {