diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/activitypub/inbox.ts | 4 | ||||
-rw-r--r-- | server/middlewares/validators/activitypub/activity.ts | 29 | ||||
-rw-r--r-- | server/models/video/video.ts | 2 |
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', | |||
19 | inboxRouter.post('/accounts/:name/inbox', | 19 | inboxRouter.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' | |||
6 | import { ActorModel } from '../../../models/activitypub/actor' | 6 | import { ActorModel } from '../../../models/activitypub/actor' |
7 | import { areValidationErrors } from '../utils' | 7 | import { areValidationErrors } from '../utils' |
8 | 8 | ||
9 | const activityPubValidator = [ | 9 | async 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 | } |