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/video-channel.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/video-channel.ts')
-rw-r--r-- | server/controllers/api/video-channel.ts | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index c13aed4dc..5881cab41 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts | |||
@@ -30,7 +30,6 @@ import { updateAvatarValidator } from '../../middlewares/validators/avatar' | |||
30 | import { updateActorAvatarFile } from '../../lib/avatar' | 30 | import { updateActorAvatarFile } from '../../lib/avatar' |
31 | import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' | 31 | import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' |
32 | import { resetSequelizeInstance } from '../../helpers/database-utils' | 32 | import { resetSequelizeInstance } from '../../helpers/database-utils' |
33 | import { UserModel } from '../../models/account/user' | ||
34 | import { JobQueue } from '../../lib/job-queue' | 33 | import { JobQueue } from '../../lib/job-queue' |
35 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 34 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
36 | import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' | 35 | import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' |
@@ -109,16 +108,16 @@ export { | |||
109 | 108 | ||
110 | // --------------------------------------------------------------------------- | 109 | // --------------------------------------------------------------------------- |
111 | 110 | ||
112 | async function listVideoChannels (req: express.Request, res: express.Response, next: express.NextFunction) { | 111 | async function listVideoChannels (req: express.Request, res: express.Response) { |
113 | const serverActor = await getServerActor() | 112 | const serverActor = await getServerActor() |
114 | const resultList = await VideoChannelModel.listForApi(serverActor.id, req.query.start, req.query.count, req.query.sort) | 113 | const resultList = await VideoChannelModel.listForApi(serverActor.id, req.query.start, req.query.count, req.query.sort) |
115 | 114 | ||
116 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | 115 | return res.json(getFormattedObjects(resultList.data, resultList.total)) |
117 | } | 116 | } |
118 | 117 | ||
119 | async function updateVideoChannelAvatar (req: express.Request, res: express.Response, next: express.NextFunction) { | 118 | async function updateVideoChannelAvatar (req: express.Request, res: express.Response) { |
120 | const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ] | 119 | const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ] |
121 | const videoChannel = res.locals.videoChannel as VideoChannelModel | 120 | const videoChannel = res.locals.videoChannel |
122 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) | 121 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) |
123 | 122 | ||
124 | const avatar = await updateActorAvatarFile(avatarPhysicalFile, videoChannel) | 123 | const avatar = await updateActorAvatarFile(avatarPhysicalFile, videoChannel) |
@@ -136,7 +135,7 @@ async function addVideoChannel (req: express.Request, res: express.Response) { | |||
136 | const videoChannelInfo: VideoChannelCreate = req.body | 135 | const videoChannelInfo: VideoChannelCreate = req.body |
137 | 136 | ||
138 | const videoChannelCreated: VideoChannelModel = await sequelizeTypescript.transaction(async t => { | 137 | const videoChannelCreated: VideoChannelModel = await sequelizeTypescript.transaction(async t => { |
139 | const account = await AccountModel.load((res.locals.oauth.token.User as UserModel).Account.id, t) | 138 | const account = await AccountModel.load(res.locals.oauth.token.User.Account.id, t) |
140 | 139 | ||
141 | return createVideoChannel(videoChannelInfo, account, t) | 140 | return createVideoChannel(videoChannelInfo, account, t) |
142 | }) | 141 | }) |
@@ -156,7 +155,7 @@ async function addVideoChannel (req: express.Request, res: express.Response) { | |||
156 | } | 155 | } |
157 | 156 | ||
158 | async function updateVideoChannel (req: express.Request, res: express.Response) { | 157 | async function updateVideoChannel (req: express.Request, res: express.Response) { |
159 | const videoChannelInstance = res.locals.videoChannel as VideoChannelModel | 158 | const videoChannelInstance = res.locals.videoChannel |
160 | const videoChannelFieldsSave = videoChannelInstance.toJSON() | 159 | const videoChannelFieldsSave = videoChannelInstance.toJSON() |
161 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannelInstance.toFormattedJSON()) | 160 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannelInstance.toFormattedJSON()) |
162 | const videoChannelInfoToUpdate = req.body as VideoChannelUpdate | 161 | const videoChannelInfoToUpdate = req.body as VideoChannelUpdate |
@@ -196,7 +195,7 @@ async function updateVideoChannel (req: express.Request, res: express.Response) | |||
196 | } | 195 | } |
197 | 196 | ||
198 | async function removeVideoChannel (req: express.Request, res: express.Response) { | 197 | async function removeVideoChannel (req: express.Request, res: express.Response) { |
199 | const videoChannelInstance: VideoChannelModel = res.locals.videoChannel | 198 | const videoChannelInstance = res.locals.videoChannel |
200 | 199 | ||
201 | await sequelizeTypescript.transaction(async t => { | 200 | await sequelizeTypescript.transaction(async t => { |
202 | await VideoPlaylistModel.resetPlaylistsOfChannel(videoChannelInstance.id, t) | 201 | await VideoPlaylistModel.resetPlaylistsOfChannel(videoChannelInstance.id, t) |
@@ -210,7 +209,7 @@ async function removeVideoChannel (req: express.Request, res: express.Response) | |||
210 | return res.type('json').status(204).end() | 209 | return res.type('json').status(204).end() |
211 | } | 210 | } |
212 | 211 | ||
213 | async function getVideoChannel (req: express.Request, res: express.Response, next: express.NextFunction) { | 212 | async function getVideoChannel (req: express.Request, res: express.Response) { |
214 | const videoChannelWithVideos = await VideoChannelModel.loadAndPopulateAccountAndVideos(res.locals.videoChannel.id) | 213 | const videoChannelWithVideos = await VideoChannelModel.loadAndPopulateAccountAndVideos(res.locals.videoChannel.id) |
215 | 214 | ||
216 | if (videoChannelWithVideos.isOutdated()) { | 215 | if (videoChannelWithVideos.isOutdated()) { |
@@ -236,8 +235,8 @@ async function listVideoChannelPlaylists (req: express.Request, res: express.Res | |||
236 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | 235 | return res.json(getFormattedObjects(resultList.data, resultList.total)) |
237 | } | 236 | } |
238 | 237 | ||
239 | async function listVideoChannelVideos (req: express.Request, res: express.Response, next: express.NextFunction) { | 238 | async function listVideoChannelVideos (req: express.Request, res: express.Response) { |
240 | const videoChannelInstance: VideoChannelModel = res.locals.videoChannel | 239 | const videoChannelInstance = res.locals.videoChannel |
241 | const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined | 240 | const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined |
242 | 241 | ||
243 | const resultList = await VideoModel.listForApi({ | 242 | const resultList = await VideoModel.listForApi({ |