From 99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 21 Aug 2018 10:34:18 +0200 Subject: Add get subscription endpoint --- server/middlewares/validators/user-subscriptions.ts | 8 ++++---- server/middlewares/validators/videos.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/middlewares/validators/user-subscriptions.ts index f331b6c34..d8c26c742 100644 --- a/server/middlewares/validators/user-subscriptions.ts +++ b/server/middlewares/validators/user-subscriptions.ts @@ -20,11 +20,11 @@ const userSubscriptionAddValidator = [ } ] -const userSubscriptionRemoveValidator = [ +const userSubscriptionGetValidator = [ param('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to unfollow'), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking unfollow parameters', { parameters: req.params }) + logger.debug('Checking userSubscriptionGetValidator parameters', { parameters: req.params }) if (areValidationErrors(req, res)) return @@ -34,7 +34,7 @@ const userSubscriptionRemoveValidator = [ const user: UserModel = res.locals.oauth.token.User const subscription = await ActorFollowModel.loadByActorAndTargetNameAndHost(user.Account.Actor.id, name, host) - if (!subscription) { + if (!subscription || !subscription.ActorFollowing.VideoChannel) { return res .status(404) .json({ @@ -52,7 +52,7 @@ const userSubscriptionRemoveValidator = [ export { userSubscriptionAddValidator, - userSubscriptionRemoveValidator + userSubscriptionGetValidator } // --------------------------------------------------------------------------- diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts index 53c32abb8..a2c866152 100644 --- a/server/middlewares/validators/videos.ts +++ b/server/middlewares/validators/videos.ts @@ -137,7 +137,7 @@ const videosGetValidator = [ // Video private or blacklisted if (video.privacy === VideoPrivacy.PRIVATE || video.VideoBlacklist) { - authenticate(req, res, () => { + return authenticate(req, res, () => { const user: UserModel = res.locals.oauth.token.User // Only the owner or a user that have blacklist rights can see the video -- cgit v1.2.3