From 99afa081bc6ae7f34b2105075bd43e3625434fa8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 15 Dec 2020 13:34:58 +0100 Subject: Add AP stats --- server/controllers/activitypub/inbox.ts | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'server/controllers/activitypub/inbox.ts') diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts index 67b2c0d66..14f301ab7 100644 --- a/server/controllers/activitypub/inbox.ts +++ b/server/controllers/activitypub/inbox.ts @@ -1,13 +1,11 @@ import * as express from 'express' +import { InboxManager } from '@server/lib/activitypub/inbox-manager' import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared' +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' import { logger } from '../../helpers/logger' -import { processActivities } from '../../lib/activitypub/process/process' import { asyncMiddleware, checkSignature, localAccountValidator, localVideoChannelValidator, signatureValidator } from '../../middlewares' import { activityPubValidator } from '../../middlewares/validators/activitypub/activity' -import { queue } from 'async' -import { MActorDefault, MActorSignature } from '../../types/models' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' const inboxRouter = express.Router() @@ -41,18 +39,6 @@ export { // --------------------------------------------------------------------------- -type QueueParam = { activities: Activity[], signatureActor?: MActorSignature, inboxActor?: MActorDefault } -const inboxQueue = queue((task, cb) => { - const options = { signatureActor: task.signatureActor, inboxActor: task.inboxActor } - - processActivities(task.activities, options) - .then(() => cb()) - .catch(err => { - logger.error('Error in process activities.', { err }) - cb() - }) -}) - function inboxController (req: express.Request, res: express.Response) { const rootActivity: RootActivity = req.body let activities: Activity[] @@ -74,10 +60,12 @@ function inboxController (req: express.Request, res: express.Response) { logger.info('Receiving inbox requests for %d activities by %s.', activities.length, res.locals.signature.actor.url) - inboxQueue.push({ + InboxManager.Instance.addInboxMessage({ activities, signatureActor: res.locals.signature.actor, - inboxActor: accountOrChannel ? accountOrChannel.Actor : undefined + inboxActor: accountOrChannel + ? accountOrChannel.Actor + : undefined }) return res.status(HttpStatusCode.NO_CONTENT_204).end() -- cgit v1.2.3