X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Factivitypub%2Finbox.ts;h=ca42106b8b27ba19d194b73d3330540cfc3ffeb6;hb=47581df0737ebcc058a5863143c752f9112a4424;hp=f0e65015bb9796fa3cc6995460db5e1c6cc79bb4;hpb=88108880bbdba473cfe36ecbebc1c3c4f972e102;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts index f0e65015b..ca42106b8 100644 --- a/server/controllers/activitypub/inbox.ts +++ b/server/controllers/activitypub/inbox.ts @@ -5,10 +5,8 @@ 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 { VideoChannelModel } from '../../models/video/video-channel' -import { AccountModel } from '../../models/account/account' import { queue } from 'async' -import { ActorModel } from '../../models/activitypub/actor' +import { MActorDefault, MActorSignature } from '../../typings/models' const inboxRouter = express.Router() @@ -42,7 +40,8 @@ export { // --------------------------------------------------------------------------- -const inboxQueue = queue<{ activities: Activity[], signatureActor?: ActorModel, inboxActor?: ActorModel }, Error>((task, cb) => { +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) @@ -66,12 +65,7 @@ function inboxController (req: express.Request, res: express.Response) { activities = activities.filter(a => isActivityValid(a)) logger.debug('We keep %d activities.', activities.length, { activities }) - let accountOrChannel: VideoChannelModel | AccountModel - if (res.locals.account) { - accountOrChannel = res.locals.account - } else if (res.locals.videoChannel) { - accountOrChannel = res.locals.videoChannel - } + const accountOrChannel = res.locals.account || res.locals.videoChannel logger.info('Receiving inbox requests for %d activities by %s.', activities.length, res.locals.signature.actor.url)