videosCustomGetValidator,
videosShareValidator
} from '../../middlewares'
-import { getAccountVideoRateValidator, videoCommentGetValidator } from '../../middlewares/validators'
+import { getAccountVideoRateValidatorFactory, videoCommentGetValidator } from '../../middlewares/validators'
import { AccountModel } from '../../models/account/account'
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
import { VideoModel } from '../../models/video/video'
)
activityPubClientRouter.get('/accounts?/:name/likes/:videoId',
executeIfActivityPub,
- asyncMiddleware(getAccountVideoRateValidator('like')),
- getAccountVideoRate('like')
+ asyncMiddleware(getAccountVideoRateValidatorFactory('like')),
+ getAccountVideoRateFactory('like')
)
activityPubClientRouter.get('/accounts?/:name/dislikes/:videoId',
executeIfActivityPub,
- asyncMiddleware(getAccountVideoRateValidator('dislike')),
- getAccountVideoRate('dislike')
+ asyncMiddleware(getAccountVideoRateValidatorFactory('dislike')),
+ getAccountVideoRateFactory('dislike')
)
activityPubClientRouter.get('/videos/watch/:id',
return activityPubResponse(activityPubContextify(activityPubResult), res)
}
-function getAccountVideoRate (rateType: VideoRateType) {
+function getAccountVideoRateFactory (rateType: VideoRateType) {
return (req: express.Request, res: express.Response) => {
const accountVideoRate = res.locals.accountVideoRate
function inboxController (req: express.Request, res: express.Response) {
const rootActivity: RootActivity = req.body
- let activities: Activity[] = []
+ let activities: Activity[]
if ([ 'Collection', 'CollectionPage' ].indexOf(rootActivity.type) !== -1) {
activities = (rootActivity as ActivityPubCollection).items
import { NextFunction, Request, Response } from 'express'
-import { ActivityPubSignature } from '../../shared'
+import { ActivityDelete, ActivityPubSignature } from '../../shared'
import { logger } from '../helpers/logger'
import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto'
import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants'
import { getOrCreateActorAndServerAndModel } from '../lib/activitypub'
import { loadActorUrlOrGetFromWebfinger } from '../helpers/webfinger'
+import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor'
async function checkSignature (req: Request, res: Response, next: NextFunction) {
try {
return next()
} catch (err) {
- logger.warn('Error in ActivityPub signature checker.', err)
+ const activity: ActivityDelete = req.body
+ if (isActorDeleteActivityValid(activity) && activity.object === activity.actor) {
+ logger.debug('Handling signature error on actor delete activity', { err })
+ return res.sendStatus(204)
+ }
+
+ logger.warn('Error in ActivityPub signature checker.', { err })
return res.sendStatus(403)
}
}
}
]
-const getAccountVideoRateValidator = function (rateType: VideoRateType) {
+const getAccountVideoRateValidatorFactory = function (rateType: VideoRateType) {
return [
param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'),
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
export {
videoUpdateRateValidator,
- getAccountVideoRateValidator,
+ getAccountVideoRateValidatorFactory,
videoRatingValidator
}