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/controllers/api/users/me.ts | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'server/controllers/api/users') diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 403842163..2300f5dbe 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts @@ -12,7 +12,7 @@ import { setDefaultPagination, setDefaultSort, userSubscriptionAddValidator, - userSubscriptionRemoveValidator, + userSubscriptionGetValidator, usersUpdateMeValidator, usersVideoRatingValidator } from '../../../middlewares' @@ -97,6 +97,17 @@ meRouter.post('/me/avatar/pick', // ##### Subscriptions part ##### +meRouter.get('/me/subscriptions/videos', + authenticate, + authenticate, + paginationValidator, + videosSortValidator, + setDefaultSort, + setDefaultPagination, + commonVideosFiltersValidator, + asyncMiddleware(getUserSubscriptionVideos) +) + meRouter.get('/me/subscriptions', authenticate, paginationValidator, @@ -112,21 +123,16 @@ meRouter.post('/me/subscriptions', asyncMiddleware(addUserSubscription) ) -meRouter.delete('/me/subscriptions/:uri', +meRouter.get('/me/subscriptions/:uri', authenticate, - userSubscriptionRemoveValidator, - asyncMiddleware(deleteUserSubscription) + userSubscriptionGetValidator, + getUserSubscription ) -meRouter.get('/me/subscriptions/videos', - authenticate, +meRouter.delete('/me/subscriptions/:uri', authenticate, - paginationValidator, - videosSortValidator, - setDefaultSort, - setDefaultPagination, - commonVideosFiltersValidator, - asyncMiddleware(getUserSubscriptionVideos) + userSubscriptionGetValidator, + asyncMiddleware(deleteUserSubscription) ) // --------------------------------------------------------------------------- @@ -153,6 +159,12 @@ async function addUserSubscription (req: express.Request, res: express.Response) return res.status(204).end() } +function getUserSubscription (req: express.Request, res: express.Response) { + const subscription: ActorFollowModel = res.locals.subscription + + return res.json(subscription.ActorFollowing.VideoChannel.toFormattedJSON()) +} + async function deleteUserSubscription (req: express.Request, res: express.Response) { const subscription: ActorFollowModel = res.locals.subscription -- cgit v1.2.3