aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/video-channel.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/video-channel.ts')
-rw-r--r--server/controllers/api/video-channel.ts19
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'
30import { updateActorAvatarFile } from '../../lib/avatar' 30import { updateActorAvatarFile } from '../../lib/avatar'
31import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' 31import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger'
32import { resetSequelizeInstance } from '../../helpers/database-utils' 32import { resetSequelizeInstance } from '../../helpers/database-utils'
33import { UserModel } from '../../models/account/user'
34import { JobQueue } from '../../lib/job-queue' 33import { JobQueue } from '../../lib/job-queue'
35import { VideoPlaylistModel } from '../../models/video/video-playlist' 34import { VideoPlaylistModel } from '../../models/video/video-playlist'
36import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' 35import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists'
@@ -109,16 +108,16 @@ export {
109 108
110// --------------------------------------------------------------------------- 109// ---------------------------------------------------------------------------
111 110
112async function listVideoChannels (req: express.Request, res: express.Response, next: express.NextFunction) { 111async 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
119async function updateVideoChannelAvatar (req: express.Request, res: express.Response, next: express.NextFunction) { 118async 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
158async function updateVideoChannel (req: express.Request, res: express.Response) { 157async 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
198async function removeVideoChannel (req: express.Request, res: express.Response) { 197async 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
213async function getVideoChannel (req: express.Request, res: express.Response, next: express.NextFunction) { 212async 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
239async function listVideoChannelVideos (req: express.Request, res: express.Response, next: express.NextFunction) { 238async 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({