diff options
author | Chocobozzz <me@florianbigard.com> | 2019-03-19 10:35:15 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-03-19 10:35:15 +0100 |
commit | dae86118ed5d4026d04acb9d0e36829b9ad8eb4e (patch) | |
tree | a5bf9c4487240bf75a9b328cad459a0587f90dea /server/controllers/api/users/my-subscriptions.ts | |
parent | e65c0c5b1fab9c3d93f51721b2458cf5cf471f20 (diff) | |
download | PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.gz PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.zst PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.zip |
Cleanup express locals typings
Diffstat (limited to 'server/controllers/api/users/my-subscriptions.ts')
-rw-r--r-- | server/controllers/api/users/my-subscriptions.ts | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts index accca6d52..a173adfd0 100644 --- a/server/controllers/api/users/my-subscriptions.ts +++ b/server/controllers/api/users/my-subscriptions.ts | |||
@@ -14,7 +14,6 @@ import { | |||
14 | userSubscriptionGetValidator | 14 | userSubscriptionGetValidator |
15 | } from '../../../middlewares' | 15 | } from '../../../middlewares' |
16 | import { areSubscriptionsExistValidator, userSubscriptionsSortValidator, videosSortValidator } from '../../../middlewares/validators' | 16 | import { areSubscriptionsExistValidator, userSubscriptionsSortValidator, videosSortValidator } from '../../../middlewares/validators' |
17 | import { UserModel } from '../../../models/account/user' | ||
18 | import { VideoModel } from '../../../models/video/video' | 17 | import { VideoModel } from '../../../models/video/video' |
19 | import { buildNSFWFilter } from '../../../helpers/express-utils' | 18 | import { buildNSFWFilter } from '../../../helpers/express-utils' |
20 | import { VideoFilter } from '../../../../shared/models/videos/video-query.type' | 19 | import { VideoFilter } from '../../../../shared/models/videos/video-query.type' |
@@ -77,7 +76,7 @@ export { | |||
77 | 76 | ||
78 | async function areSubscriptionsExist (req: express.Request, res: express.Response) { | 77 | async function areSubscriptionsExist (req: express.Request, res: express.Response) { |
79 | const uris = req.query.uris as string[] | 78 | const uris = req.query.uris as string[] |
80 | const user = res.locals.oauth.token.User as UserModel | 79 | const user = res.locals.oauth.token.User |
81 | 80 | ||
82 | const handles = uris.map(u => { | 81 | const handles = uris.map(u => { |
83 | let [ name, host ] = u.split('@') | 82 | let [ name, host ] = u.split('@') |
@@ -107,7 +106,7 @@ async function areSubscriptionsExist (req: express.Request, res: express.Respons | |||
107 | } | 106 | } |
108 | 107 | ||
109 | async function addUserSubscription (req: express.Request, res: express.Response) { | 108 | async function addUserSubscription (req: express.Request, res: express.Response) { |
110 | const user = res.locals.oauth.token.User as UserModel | 109 | const user = res.locals.oauth.token.User |
111 | const [ name, host ] = req.body.uri.split('@') | 110 | const [ name, host ] = req.body.uri.split('@') |
112 | 111 | ||
113 | const payload = { | 112 | const payload = { |
@@ -123,13 +122,13 @@ async function addUserSubscription (req: express.Request, res: express.Response) | |||
123 | } | 122 | } |
124 | 123 | ||
125 | function getUserSubscription (req: express.Request, res: express.Response) { | 124 | function getUserSubscription (req: express.Request, res: express.Response) { |
126 | const subscription: ActorFollowModel = res.locals.subscription | 125 | const subscription = res.locals.subscription |
127 | 126 | ||
128 | return res.json(subscription.ActorFollowing.VideoChannel.toFormattedJSON()) | 127 | return res.json(subscription.ActorFollowing.VideoChannel.toFormattedJSON()) |
129 | } | 128 | } |
130 | 129 | ||
131 | async function deleteUserSubscription (req: express.Request, res: express.Response) { | 130 | async function deleteUserSubscription (req: express.Request, res: express.Response) { |
132 | const subscription: ActorFollowModel = res.locals.subscription | 131 | const subscription = res.locals.subscription |
133 | 132 | ||
134 | await sequelizeTypescript.transaction(async t => { | 133 | await sequelizeTypescript.transaction(async t => { |
135 | return subscription.destroy({ transaction: t }) | 134 | return subscription.destroy({ transaction: t }) |
@@ -139,7 +138,7 @@ async function deleteUserSubscription (req: express.Request, res: express.Respon | |||
139 | } | 138 | } |
140 | 139 | ||
141 | async function getUserSubscriptions (req: express.Request, res: express.Response) { | 140 | async function getUserSubscriptions (req: express.Request, res: express.Response) { |
142 | const user = res.locals.oauth.token.User as UserModel | 141 | const user = res.locals.oauth.token.User |
143 | const actorId = user.Account.Actor.id | 142 | const actorId = user.Account.Actor.id |
144 | 143 | ||
145 | const resultList = await ActorFollowModel.listSubscriptionsForApi(actorId, req.query.start, req.query.count, req.query.sort) | 144 | const resultList = await ActorFollowModel.listSubscriptionsForApi(actorId, req.query.start, req.query.count, req.query.sort) |
@@ -147,8 +146,8 @@ async function getUserSubscriptions (req: express.Request, res: express.Response | |||
147 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | 146 | return res.json(getFormattedObjects(resultList.data, resultList.total)) |
148 | } | 147 | } |
149 | 148 | ||
150 | async function getUserSubscriptionVideos (req: express.Request, res: express.Response, next: express.NextFunction) { | 149 | async function getUserSubscriptionVideos (req: express.Request, res: express.Response) { |
151 | const user = res.locals.oauth.token.User as UserModel | 150 | const user = res.locals.oauth.token.User |
152 | const resultList = await VideoModel.listForApi({ | 151 | const resultList = await VideoModel.listForApi({ |
153 | start: req.query.start, | 152 | start: req.query.start, |
154 | count: req.query.count, | 153 | count: req.query.count, |