aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-12-15 13:34:58 +0100
committerChocobozzz <me@florianbigard.com>2020-12-15 13:34:58 +0100
commit99afa081bc6ae7f34b2105075bd43e3625434fa8 (patch)
tree0caea8591b3d3688a133cf33edcad616bf276375 /server/controllers/activitypub
parent48586fe070c2a59e9febb62a7f41ebb384e1d20e (diff)
downloadPeerTube-99afa081bc6ae7f34b2105075bd43e3625434fa8.tar.gz
PeerTube-99afa081bc6ae7f34b2105075bd43e3625434fa8.tar.zst
PeerTube-99afa081bc6ae7f34b2105075bd43e3625434fa8.zip
Add AP stats
Diffstat (limited to 'server/controllers/activitypub')
-rw-r--r--server/controllers/activitypub/inbox.ts24
1 files changed, 6 insertions, 18 deletions
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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { InboxManager } from '@server/lib/activitypub/inbox-manager'
2import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared' 3import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared'
4import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
3import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' 5import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity'
4import { logger } from '../../helpers/logger' 6import { logger } from '../../helpers/logger'
5import { processActivities } from '../../lib/activitypub/process/process'
6import { asyncMiddleware, checkSignature, localAccountValidator, localVideoChannelValidator, signatureValidator } from '../../middlewares' 7import { asyncMiddleware, checkSignature, localAccountValidator, localVideoChannelValidator, signatureValidator } from '../../middlewares'
7import { activityPubValidator } from '../../middlewares/validators/activitypub/activity' 8import { activityPubValidator } from '../../middlewares/validators/activitypub/activity'
8import { queue } from 'async'
9import { MActorDefault, MActorSignature } from '../../types/models'
10import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
11 9
12const inboxRouter = express.Router() 10const inboxRouter = express.Router()
13 11
@@ -41,18 +39,6 @@ export {
41 39
42// --------------------------------------------------------------------------- 40// ---------------------------------------------------------------------------
43 41
44type QueueParam = { activities: Activity[], signatureActor?: MActorSignature, inboxActor?: MActorDefault }
45const inboxQueue = queue<QueueParam, Error>((task, cb) => {
46 const options = { signatureActor: task.signatureActor, inboxActor: task.inboxActor }
47
48 processActivities(task.activities, options)
49 .then(() => cb())
50 .catch(err => {
51 logger.error('Error in process activities.', { err })
52 cb()
53 })
54})
55
56function inboxController (req: express.Request, res: express.Response) { 42function inboxController (req: express.Request, res: express.Response) {
57 const rootActivity: RootActivity = req.body 43 const rootActivity: RootActivity = req.body
58 let activities: Activity[] 44 let activities: Activity[]
@@ -74,10 +60,12 @@ function inboxController (req: express.Request, res: express.Response) {
74 60
75 logger.info('Receiving inbox requests for %d activities by %s.', activities.length, res.locals.signature.actor.url) 61 logger.info('Receiving inbox requests for %d activities by %s.', activities.length, res.locals.signature.actor.url)
76 62
77 inboxQueue.push({ 63 InboxManager.Instance.addInboxMessage({
78 activities, 64 activities,
79 signatureActor: res.locals.signature.actor, 65 signatureActor: res.locals.signature.actor,
80 inboxActor: accountOrChannel ? accountOrChannel.Actor : undefined 66 inboxActor: accountOrChannel
67 ? accountOrChannel.Actor
68 : undefined
81 }) 69 })
82 70
83 return res.status(HttpStatusCode.NO_CONTENT_204).end() 71 return res.status(HttpStatusCode.NO_CONTENT_204).end()