aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-21 10:34:18 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 09:41:54 +0200
commit99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd (patch)
treee442f6cdf0cb622cb78f64d0d9de23bfb6deb951 /server/controllers/api/users
parent8a19bee1a1ee39f973bb37429e4f73c3f2873cdb (diff)
downloadPeerTube-99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd.tar.gz
PeerTube-99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd.tar.zst
PeerTube-99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd.zip
Add get subscription endpoint
Diffstat (limited to 'server/controllers/api/users')
-rw-r--r--server/controllers/api/users/me.ts36
1 files changed, 24 insertions, 12 deletions
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 {
12 setDefaultPagination, 12 setDefaultPagination,
13 setDefaultSort, 13 setDefaultSort,
14 userSubscriptionAddValidator, 14 userSubscriptionAddValidator,
15 userSubscriptionRemoveValidator, 15 userSubscriptionGetValidator,
16 usersUpdateMeValidator, 16 usersUpdateMeValidator,
17 usersVideoRatingValidator 17 usersVideoRatingValidator
18} from '../../../middlewares' 18} from '../../../middlewares'
@@ -97,6 +97,17 @@ meRouter.post('/me/avatar/pick',
97 97
98// ##### Subscriptions part ##### 98// ##### Subscriptions part #####
99 99
100meRouter.get('/me/subscriptions/videos',
101 authenticate,
102 authenticate,
103 paginationValidator,
104 videosSortValidator,
105 setDefaultSort,
106 setDefaultPagination,
107 commonVideosFiltersValidator,
108 asyncMiddleware(getUserSubscriptionVideos)
109)
110
100meRouter.get('/me/subscriptions', 111meRouter.get('/me/subscriptions',
101 authenticate, 112 authenticate,
102 paginationValidator, 113 paginationValidator,
@@ -112,21 +123,16 @@ meRouter.post('/me/subscriptions',
112 asyncMiddleware(addUserSubscription) 123 asyncMiddleware(addUserSubscription)
113) 124)
114 125
115meRouter.delete('/me/subscriptions/:uri', 126meRouter.get('/me/subscriptions/:uri',
116 authenticate, 127 authenticate,
117 userSubscriptionRemoveValidator, 128 userSubscriptionGetValidator,
118 asyncMiddleware(deleteUserSubscription) 129 getUserSubscription
119) 130)
120 131
121meRouter.get('/me/subscriptions/videos', 132meRouter.delete('/me/subscriptions/:uri',
122 authenticate,
123 authenticate, 133 authenticate,
124 paginationValidator, 134 userSubscriptionGetValidator,
125 videosSortValidator, 135 asyncMiddleware(deleteUserSubscription)
126 setDefaultSort,
127 setDefaultPagination,
128 commonVideosFiltersValidator,
129 asyncMiddleware(getUserSubscriptionVideos)
130) 136)
131 137
132// --------------------------------------------------------------------------- 138// ---------------------------------------------------------------------------
@@ -153,6 +159,12 @@ async function addUserSubscription (req: express.Request, res: express.Response)
153 return res.status(204).end() 159 return res.status(204).end()
154} 160}
155 161
162function getUserSubscription (req: express.Request, res: express.Response) {
163 const subscription: ActorFollowModel = res.locals.subscription
164
165 return res.json(subscription.ActorFollowing.VideoChannel.toFormattedJSON())
166}
167
156async function deleteUserSubscription (req: express.Request, res: express.Response) { 168async function deleteUserSubscription (req: express.Request, res: express.Response) {
157 const subscription: ActorFollowModel = res.locals.subscription 169 const subscription: ActorFollowModel = res.locals.subscription
158 170