aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users/my-subscriptions.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-03-19 10:35:15 +0100
committerChocobozzz <me@florianbigard.com>2019-03-19 10:35:15 +0100
commitdae86118ed5d4026d04acb9d0e36829b9ad8eb4e (patch)
treea5bf9c4487240bf75a9b328cad459a0587f90dea /server/controllers/api/users/my-subscriptions.ts
parente65c0c5b1fab9c3d93f51721b2458cf5cf471f20 (diff)
downloadPeerTube-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.ts15
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'
16import { areSubscriptionsExistValidator, userSubscriptionsSortValidator, videosSortValidator } from '../../../middlewares/validators' 16import { areSubscriptionsExistValidator, userSubscriptionsSortValidator, videosSortValidator } from '../../../middlewares/validators'
17import { UserModel } from '../../../models/account/user'
18import { VideoModel } from '../../../models/video/video' 17import { VideoModel } from '../../../models/video/video'
19import { buildNSFWFilter } from '../../../helpers/express-utils' 18import { buildNSFWFilter } from '../../../helpers/express-utils'
20import { VideoFilter } from '../../../../shared/models/videos/video-query.type' 19import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
@@ -77,7 +76,7 @@ export {
77 76
78async function areSubscriptionsExist (req: express.Request, res: express.Response) { 77async 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
109async function addUserSubscription (req: express.Request, res: express.Response) { 108async 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
125function getUserSubscription (req: express.Request, res: express.Response) { 124function 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
131async function deleteUserSubscription (req: express.Request, res: express.Response) { 130async 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
141async function getUserSubscriptions (req: express.Request, res: express.Response) { 140async 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
150async function getUserSubscriptionVideos (req: express.Request, res: express.Response, next: express.NextFunction) { 149async 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,