mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
Add AP stats
This commit is contained in:
parent
48586fe070
commit
99afa081bc
7 changed files with 193 additions and 70 deletions
|
@ -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<QueueParam, Error>((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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue