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.ts24
1 files changed, 19 insertions, 5 deletions
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index 2454b1ec9..411ec8630 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -126,7 +126,7 @@ videoChannelRouter.delete('/:nameWithHost',
126 126
127videoChannelRouter.get('/:nameWithHost', 127videoChannelRouter.get('/:nameWithHost',
128 asyncMiddleware(videoChannelsNameWithHostValidator), 128 asyncMiddleware(videoChannelsNameWithHostValidator),
129 getVideoChannel 129 asyncMiddleware(getVideoChannel)
130) 130)
131 131
132videoChannelRouter.get('/:nameWithHost/video-playlists', 132videoChannelRouter.get('/:nameWithHost/video-playlists',
@@ -171,12 +171,19 @@ export {
171 171
172async function listVideoChannels (req: express.Request, res: express.Response) { 172async function listVideoChannels (req: express.Request, res: express.Response) {
173 const serverActor = await getServerActor() 173 const serverActor = await getServerActor()
174 const resultList = await VideoChannelModel.listForApi({ 174
175 const apiOptions = await Hooks.wrapObject({
175 actorId: serverActor.id, 176 actorId: serverActor.id,
176 start: req.query.start, 177 start: req.query.start,
177 count: req.query.count, 178 count: req.query.count,
178 sort: req.query.sort 179 sort: req.query.sort
179 }) 180 }, 'filter:api.video-channels.list.params')
181
182 const resultList = await Hooks.wrapPromiseFun(
183 VideoChannelModel.listForApi,
184 apiOptions,
185 'filter:api.video-channels.list.result'
186 )
180 187
181 return res.json(getFormattedObjects(resultList.data, resultList.total)) 188 return res.json(getFormattedObjects(resultList.data, resultList.total))
182} 189}
@@ -243,6 +250,8 @@ async function addVideoChannel (req: express.Request, res: express.Response) {
243 auditLogger.create(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelCreated.toFormattedJSON())) 250 auditLogger.create(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelCreated.toFormattedJSON()))
244 logger.info('Video channel %s created.', videoChannelCreated.Actor.url) 251 logger.info('Video channel %s created.', videoChannelCreated.Actor.url)
245 252
253 Hooks.runAction('action:api.video-channel.created', { videoChannel: videoChannelCreated, req, res })
254
246 return res.json({ 255 return res.json({
247 videoChannel: { 256 videoChannel: {
248 id: videoChannelCreated.id 257 id: videoChannelCreated.id
@@ -281,6 +290,8 @@ async function updateVideoChannel (req: express.Request, res: express.Response)
281 oldVideoChannelAuditKeys 290 oldVideoChannelAuditKeys
282 ) 291 )
283 292
293 Hooks.runAction('action:api.video-channel.updated', { videoChannel: videoChannelInstanceUpdated, req, res })
294
284 logger.info('Video channel %s updated.', videoChannelInstance.Actor.url) 295 logger.info('Video channel %s updated.', videoChannelInstance.Actor.url)
285 }) 296 })
286 } catch (err) { 297 } catch (err) {
@@ -310,6 +321,8 @@ async function removeVideoChannel (req: express.Request, res: express.Response)
310 321
311 await videoChannelInstance.destroy({ transaction: t }) 322 await videoChannelInstance.destroy({ transaction: t })
312 323
324 Hooks.runAction('action:api.video-channel.deleted', { videoChannel: videoChannelInstance, req, res })
325
313 auditLogger.delete(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelInstance.toFormattedJSON())) 326 auditLogger.delete(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelInstance.toFormattedJSON()))
314 logger.info('Video channel %s deleted.', videoChannelInstance.Actor.url) 327 logger.info('Video channel %s deleted.', videoChannelInstance.Actor.url)
315 }) 328 })
@@ -317,8 +330,9 @@ async function removeVideoChannel (req: express.Request, res: express.Response)
317 return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() 330 return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
318} 331}
319 332
320function getVideoChannel (req: express.Request, res: express.Response) { 333async function getVideoChannel (req: express.Request, res: express.Response) {
321 const videoChannel = res.locals.videoChannel 334 const id = res.locals.videoChannel.id
335 const videoChannel = await Hooks.wrapObject(res.locals.videoChannel, 'filter:api.video-channel.get.result', { id })
322 336
323 if (videoChannel.isOutdated()) { 337 if (videoChannel.isOutdated()) {
324 JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'actor', url: videoChannel.Actor.url } }) 338 JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'actor', url: videoChannel.Actor.url } })