aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-04-06 11:54:24 +0200
committerChocobozzz <me@florianbigard.com>2018-04-06 14:39:19 +0200
commitee28cdf1c488ac6ad6f3d06804b9c5e63eea1965 (patch)
tree23c614a34d09b565b3c428a77df72541d4653418 /server
parent228e84aa7e604c010ecc39bd54b62fefcca3b94e (diff)
downloadPeerTube-ee28cdf1c488ac6ad6f3d06804b9c5e63eea1965.tar.gz
PeerTube-ee28cdf1c488ac6ad6f3d06804b9c5e63eea1965.tar.zst
PeerTube-ee28cdf1c488ac6ad6f3d06804b9c5e63eea1965.zip
Upgrade server dependencies
Diffstat (limited to 'server')
-rw-r--r--server/controllers/activitypub/inbox.ts4
-rw-r--r--server/middlewares/validators/activitypub/activity.ts29
-rw-r--r--server/models/video/video.ts2
3 files changed, 18 insertions, 17 deletions
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts
index df041aebf..73fbd94aa 100644
--- a/server/controllers/activitypub/inbox.ts
+++ b/server/controllers/activitypub/inbox.ts
@@ -19,7 +19,7 @@ inboxRouter.post('/inbox',
19inboxRouter.post('/accounts/:name/inbox', 19inboxRouter.post('/accounts/:name/inbox',
20 signatureValidator, 20 signatureValidator,
21 asyncMiddleware(checkSignature), 21 asyncMiddleware(checkSignature),
22 localAccountValidator, 22 asyncMiddleware(localAccountValidator),
23 asyncMiddleware(activityPubValidator), 23 asyncMiddleware(activityPubValidator),
24 asyncMiddleware(inboxController) 24 asyncMiddleware(inboxController)
25) 25)
@@ -36,6 +36,8 @@ async function inboxController (req: express.Request, res: express.Response, nex
36 const rootActivity: RootActivity = req.body 36 const rootActivity: RootActivity = req.body
37 let activities: Activity[] = [] 37 let activities: Activity[] = []
38 38
39 console.log(rootActivity)
40
39 if ([ 'Collection', 'CollectionPage' ].indexOf(rootActivity.type) !== -1) { 41 if ([ 'Collection', 'CollectionPage' ].indexOf(rootActivity.type) !== -1) {
40 activities = (rootActivity as ActivityPubCollection).items 42 activities = (rootActivity as ActivityPubCollection).items
41 } else if ([ 'OrderedCollection', 'OrderedCollectionPage' ].indexOf(rootActivity.type) !== -1) { 43 } else if ([ 'OrderedCollection', 'OrderedCollectionPage' ].indexOf(rootActivity.type) !== -1) {
diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/middlewares/validators/activitypub/activity.ts
index 8c2920328..4aace4c8e 100644
--- a/server/middlewares/validators/activitypub/activity.ts
+++ b/server/middlewares/validators/activitypub/activity.ts
@@ -6,24 +6,23 @@ import { getServerActor } from '../../../helpers/utils'
6import { ActorModel } from '../../../models/activitypub/actor' 6import { ActorModel } from '../../../models/activitypub/actor'
7import { areValidationErrors } from '../utils' 7import { areValidationErrors } from '../utils'
8 8
9const activityPubValidator = [ 9async function activityPubValidator (req: express.Request, res: express.Response, next: express.NextFunction) {
10 body('').custom((value, { req }) => isRootActivityValid(req.body)), 10 logger.debug('Checking activity pub parameters')
11 11
12 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 12 if (!isRootActivityValid(req.body)) {
13 logger.debug('Checking activity pub parameters') 13 logger.warn('Incorrect activity parameters.', { activity: req.body })
14 14 return res.status(400).json({ error: 'Incorrect activity.' })
15 if (areValidationErrors(req, res)) return 15 }
16
17 const serverActor = await getServerActor()
18 const remoteActor = res.locals.signature.actor as ActorModel
19 if (serverActor.id === remoteActor.id) {
20 logger.error('Receiving request in INBOX by ourselves!', req.body)
21 return res.status(409).end()
22 }
23 16
24 return next() 17 const serverActor = await getServerActor()
18 const remoteActor = res.locals.signature.actor as ActorModel
19 if (serverActor.id === remoteActor.id) {
20 logger.error('Receiving request in INBOX by ourselves!', req.body)
21 return res.status(409).end()
25 } 22 }
26] 23
24 return next()
25}
27 26
28// --------------------------------------------------------------------------- 27// ---------------------------------------------------------------------------
29 28
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 8b58b393b..54fe54535 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1000,7 +1000,7 @@ export class VideoModel extends Model<VideoModel> {
1000 descriptionPath: this.getDescriptionPath(), 1000 descriptionPath: this.getDescriptionPath(),
1001 channel: this.VideoChannel.toFormattedJSON(), 1001 channel: this.VideoChannel.toFormattedJSON(),
1002 account: this.VideoChannel.Account.toFormattedJSON(), 1002 account: this.VideoChannel.Account.toFormattedJSON(),
1003 tags: map<TagModel, string>(this.Tags, 'name'), 1003 tags: map(this.Tags, 'name'),
1004 commentsEnabled: this.commentsEnabled, 1004 commentsEnabled: this.commentsEnabled,
1005 files: [] 1005 files: []
1006 } 1006 }