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.ts55
1 files changed, 45 insertions, 10 deletions
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index b79dc5933..f370c7004 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -1,6 +1,7 @@
1import express from 'express' 1import express from 'express'
2import { pickCommonVideoQuery } from '@server/helpers/query' 2import { pickCommonVideoQuery } from '@server/helpers/query'
3import { Hooks } from '@server/lib/plugins/hooks' 3import { Hooks } from '@server/lib/plugins/hooks'
4import { ActorFollowModel } from '@server/models/actor/actor-follow'
4import { getServerActor } from '@server/models/application/application' 5import { getServerActor } from '@server/models/application/application'
5import { MChannelBannerAccountDefault } from '@server/types/models' 6import { MChannelBannerAccountDefault } from '@server/types/models'
6import { ActorImageType, VideoChannelCreate, VideoChannelUpdate } from '../../../shared' 7import { ActorImageType, VideoChannelCreate, VideoChannelUpdate } from '../../../shared'
@@ -33,7 +34,13 @@ import {
33 videoChannelsUpdateValidator, 34 videoChannelsUpdateValidator,
34 videoPlaylistsSortValidator 35 videoPlaylistsSortValidator
35} from '../../middlewares' 36} from '../../middlewares'
36import { videoChannelsListValidator, videoChannelsNameWithHostValidator, videosSortValidator } from '../../middlewares/validators' 37import {
38 ensureAuthUserOwnsChannelValidator,
39 videoChannelsFollowersSortValidator,
40 videoChannelsListValidator,
41 videoChannelsNameWithHostValidator,
42 videosSortValidator
43} from '../../middlewares/validators'
37import { updateAvatarValidator, updateBannerValidator } from '../../middlewares/validators/actor-image' 44import { updateAvatarValidator, updateBannerValidator } from '../../middlewares/validators/actor-image'
38import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' 45import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists'
39import { AccountModel } from '../../models/account/account' 46import { AccountModel } from '../../models/account/account'
@@ -65,8 +72,8 @@ videoChannelRouter.post('/',
65videoChannelRouter.post('/:nameWithHost/avatar/pick', 72videoChannelRouter.post('/:nameWithHost/avatar/pick',
66 authenticate, 73 authenticate,
67 reqAvatarFile, 74 reqAvatarFile,
68 // Check the rights 75 asyncMiddleware(videoChannelsNameWithHostValidator),
69 asyncMiddleware(videoChannelsUpdateValidator), 76 ensureAuthUserOwnsChannelValidator,
70 updateAvatarValidator, 77 updateAvatarValidator,
71 asyncMiddleware(updateVideoChannelAvatar) 78 asyncMiddleware(updateVideoChannelAvatar)
72) 79)
@@ -74,29 +81,31 @@ videoChannelRouter.post('/:nameWithHost/avatar/pick',
74videoChannelRouter.post('/:nameWithHost/banner/pick', 81videoChannelRouter.post('/:nameWithHost/banner/pick',
75 authenticate, 82 authenticate,
76 reqBannerFile, 83 reqBannerFile,
77 // Check the rights 84 asyncMiddleware(videoChannelsNameWithHostValidator),
78 asyncMiddleware(videoChannelsUpdateValidator), 85 ensureAuthUserOwnsChannelValidator,
79 updateBannerValidator, 86 updateBannerValidator,
80 asyncMiddleware(updateVideoChannelBanner) 87 asyncMiddleware(updateVideoChannelBanner)
81) 88)
82 89
83videoChannelRouter.delete('/:nameWithHost/avatar', 90videoChannelRouter.delete('/:nameWithHost/avatar',
84 authenticate, 91 authenticate,
85 // Check the rights 92 asyncMiddleware(videoChannelsNameWithHostValidator),
86 asyncMiddleware(videoChannelsUpdateValidator), 93 ensureAuthUserOwnsChannelValidator,
87 asyncMiddleware(deleteVideoChannelAvatar) 94 asyncMiddleware(deleteVideoChannelAvatar)
88) 95)
89 96
90videoChannelRouter.delete('/:nameWithHost/banner', 97videoChannelRouter.delete('/:nameWithHost/banner',
91 authenticate, 98 authenticate,
92 // Check the rights 99 asyncMiddleware(videoChannelsNameWithHostValidator),
93 asyncMiddleware(videoChannelsUpdateValidator), 100 ensureAuthUserOwnsChannelValidator,
94 asyncMiddleware(deleteVideoChannelBanner) 101 asyncMiddleware(deleteVideoChannelBanner)
95) 102)
96 103
97videoChannelRouter.put('/:nameWithHost', 104videoChannelRouter.put('/:nameWithHost',
98 authenticate, 105 authenticate,
99 asyncMiddleware(videoChannelsUpdateValidator), 106 asyncMiddleware(videoChannelsNameWithHostValidator),
107 ensureAuthUserOwnsChannelValidator,
108 videoChannelsUpdateValidator,
100 asyncRetryTransactionMiddleware(updateVideoChannel) 109 asyncRetryTransactionMiddleware(updateVideoChannel)
101) 110)
102 111
@@ -132,6 +141,17 @@ videoChannelRouter.get('/:nameWithHost/videos',
132 asyncMiddleware(listVideoChannelVideos) 141 asyncMiddleware(listVideoChannelVideos)
133) 142)
134 143
144videoChannelRouter.get('/:nameWithHost/followers',
145 authenticate,
146 asyncMiddleware(videoChannelsNameWithHostValidator),
147 ensureAuthUserOwnsChannelValidator,
148 paginationValidator,
149 videoChannelsFollowersSortValidator,
150 setDefaultSort,
151 setDefaultPagination,
152 asyncMiddleware(listVideoChannelFollowers)
153)
154
135// --------------------------------------------------------------------------- 155// ---------------------------------------------------------------------------
136 156
137export { 157export {
@@ -332,3 +352,18 @@ async function listVideoChannelVideos (req: express.Request, res: express.Respon
332 352
333 return res.json(getFormattedObjects(resultList.data, resultList.total)) 353 return res.json(getFormattedObjects(resultList.data, resultList.total))
334} 354}
355
356async function listVideoChannelFollowers (req: express.Request, res: express.Response) {
357 const channel = res.locals.videoChannel
358
359 const resultList = await ActorFollowModel.listFollowersForApi({
360 actorIds: [ channel.actorId ],
361 start: req.query.start,
362 count: req.query.count,
363 sort: req.query.sort,
364 search: req.query.search,
365 state: 'accepted',
366 })
367
368 return res.json(getFormattedObjects(resultList.data, resultList.total))
369}