diff options
-rw-r--r-- | server/controllers/activitypub/client.ts | 12 | ||||
-rw-r--r-- | server/controllers/activitypub/inbox.ts | 2 | ||||
-rw-r--r-- | server/middlewares/activitypub.ts | 11 | ||||
-rw-r--r-- | server/middlewares/validators/videos/video-rates.ts | 4 |
4 files changed, 18 insertions, 11 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index 62412cd62..95c2a26a6 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -14,7 +14,7 @@ import { | |||
14 | videosCustomGetValidator, | 14 | videosCustomGetValidator, |
15 | videosShareValidator | 15 | videosShareValidator |
16 | } from '../../middlewares' | 16 | } from '../../middlewares' |
17 | import { getAccountVideoRateValidator, videoCommentGetValidator } from '../../middlewares/validators' | 17 | import { getAccountVideoRateValidatorFactory, videoCommentGetValidator } from '../../middlewares/validators' |
18 | import { AccountModel } from '../../models/account/account' | 18 | import { AccountModel } from '../../models/account/account' |
19 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' | 19 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' |
20 | import { VideoModel } from '../../models/video/video' | 20 | import { VideoModel } from '../../models/video/video' |
@@ -63,13 +63,13 @@ activityPubClientRouter.get('/accounts?/:name/playlists', | |||
63 | ) | 63 | ) |
64 | activityPubClientRouter.get('/accounts?/:name/likes/:videoId', | 64 | activityPubClientRouter.get('/accounts?/:name/likes/:videoId', |
65 | executeIfActivityPub, | 65 | executeIfActivityPub, |
66 | asyncMiddleware(getAccountVideoRateValidator('like')), | 66 | asyncMiddleware(getAccountVideoRateValidatorFactory('like')), |
67 | getAccountVideoRate('like') | 67 | getAccountVideoRateFactory('like') |
68 | ) | 68 | ) |
69 | activityPubClientRouter.get('/accounts?/:name/dislikes/:videoId', | 69 | activityPubClientRouter.get('/accounts?/:name/dislikes/:videoId', |
70 | executeIfActivityPub, | 70 | executeIfActivityPub, |
71 | asyncMiddleware(getAccountVideoRateValidator('dislike')), | 71 | asyncMiddleware(getAccountVideoRateValidatorFactory('dislike')), |
72 | getAccountVideoRate('dislike') | 72 | getAccountVideoRateFactory('dislike') |
73 | ) | 73 | ) |
74 | 74 | ||
75 | activityPubClientRouter.get('/videos/watch/:id', | 75 | activityPubClientRouter.get('/videos/watch/:id', |
@@ -192,7 +192,7 @@ async function accountPlaylistsController (req: express.Request, res: express.Re | |||
192 | return activityPubResponse(activityPubContextify(activityPubResult), res) | 192 | return activityPubResponse(activityPubContextify(activityPubResult), res) |
193 | } | 193 | } |
194 | 194 | ||
195 | function getAccountVideoRate (rateType: VideoRateType) { | 195 | function getAccountVideoRateFactory (rateType: VideoRateType) { |
196 | return (req: express.Request, res: express.Response) => { | 196 | return (req: express.Request, res: express.Response) => { |
197 | const accountVideoRate = res.locals.accountVideoRate | 197 | const accountVideoRate = res.locals.accountVideoRate |
198 | 198 | ||
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts index ca42106b8..4fb180003 100644 --- a/server/controllers/activitypub/inbox.ts +++ b/server/controllers/activitypub/inbox.ts | |||
@@ -50,7 +50,7 @@ const inboxQueue = queue<QueueParam, Error>((task, cb) => { | |||
50 | 50 | ||
51 | function inboxController (req: express.Request, res: express.Response) { | 51 | function inboxController (req: express.Request, res: express.Response) { |
52 | const rootActivity: RootActivity = req.body | 52 | const rootActivity: RootActivity = req.body |
53 | let activities: Activity[] = [] | 53 | let activities: Activity[] |
54 | 54 | ||
55 | if ([ 'Collection', 'CollectionPage' ].indexOf(rootActivity.type) !== -1) { | 55 | if ([ 'Collection', 'CollectionPage' ].indexOf(rootActivity.type) !== -1) { |
56 | activities = (rootActivity as ActivityPubCollection).items | 56 | activities = (rootActivity as ActivityPubCollection).items |
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts index c906e785c..f3feae41e 100644 --- a/server/middlewares/activitypub.ts +++ b/server/middlewares/activitypub.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import { NextFunction, Request, Response } from 'express' | 1 | import { NextFunction, Request, Response } from 'express' |
2 | import { ActivityPubSignature } from '../../shared' | 2 | import { ActivityDelete, ActivityPubSignature } from '../../shared' |
3 | import { logger } from '../helpers/logger' | 3 | import { logger } from '../helpers/logger' |
4 | import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto' | 4 | import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto' |
5 | import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants' | 5 | import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants' |
6 | import { getOrCreateActorAndServerAndModel } from '../lib/activitypub' | 6 | import { getOrCreateActorAndServerAndModel } from '../lib/activitypub' |
7 | import { loadActorUrlOrGetFromWebfinger } from '../helpers/webfinger' | 7 | import { loadActorUrlOrGetFromWebfinger } from '../helpers/webfinger' |
8 | import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor' | ||
8 | 9 | ||
9 | async function checkSignature (req: Request, res: Response, next: NextFunction) { | 10 | async function checkSignature (req: Request, res: Response, next: NextFunction) { |
10 | try { | 11 | try { |
@@ -23,7 +24,13 @@ async function checkSignature (req: Request, res: Response, next: NextFunction) | |||
23 | 24 | ||
24 | return next() | 25 | return next() |
25 | } catch (err) { | 26 | } catch (err) { |
26 | logger.warn('Error in ActivityPub signature checker.', err) | 27 | const activity: ActivityDelete = req.body |
28 | if (isActorDeleteActivityValid(activity) && activity.object === activity.actor) { | ||
29 | logger.debug('Handling signature error on actor delete activity', { err }) | ||
30 | return res.sendStatus(204) | ||
31 | } | ||
32 | |||
33 | logger.warn('Error in ActivityPub signature checker.', { err }) | ||
27 | return res.sendStatus(403) | 34 | return res.sendStatus(403) |
28 | } | 35 | } |
29 | } | 36 | } |
diff --git a/server/middlewares/validators/videos/video-rates.ts b/server/middlewares/validators/videos/video-rates.ts index 4021cfecc..5d5fae8aa 100644 --- a/server/middlewares/validators/videos/video-rates.ts +++ b/server/middlewares/validators/videos/video-rates.ts | |||
@@ -24,7 +24,7 @@ const videoUpdateRateValidator = [ | |||
24 | } | 24 | } |
25 | ] | 25 | ] |
26 | 26 | ||
27 | const getAccountVideoRateValidator = function (rateType: VideoRateType) { | 27 | const getAccountVideoRateValidatorFactory = function (rateType: VideoRateType) { |
28 | return [ | 28 | return [ |
29 | param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'), | 29 | param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'), |
30 | param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), | 30 | param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), |
@@ -64,6 +64,6 @@ const videoRatingValidator = [ | |||
64 | 64 | ||
65 | export { | 65 | export { |
66 | videoUpdateRateValidator, | 66 | videoUpdateRateValidator, |
67 | getAccountVideoRateValidator, | 67 | getAccountVideoRateValidatorFactory, |
68 | videoRatingValidator | 68 | videoRatingValidator |
69 | } | 69 | } |