]>
Commit | Line | Data |
---|---|---|
41fb13c3 | 1 | import express from 'express' |
d6886027 | 2 | import { pickCommonVideoQuery } from '@server/helpers/query' |
d0800f76 | 3 | import { getBiggestActorImage } from '@server/lib/actor-image' |
38267c0c | 4 | import { Hooks } from '@server/lib/plugins/hooks' |
4beda9e1 | 5 | import { ActorFollowModel } from '@server/models/actor/actor-follow' |
8054669f | 6 | import { getServerActor } from '@server/models/application/application' |
2760b454 | 7 | import { guessAdditionalAttributesFromQuery } from '@server/models/video/formatter/video-format-utils' |
2cb03dc1 | 8 | import { MChannelBannerAccountDefault } from '@server/types/models' |
a3b472a1 | 9 | import { ActorImageType, HttpStatusCode, VideoChannelCreate, VideoChannelUpdate, VideosImportInChannelCreate } from '@shared/models' |
8054669f C |
10 | import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' |
11 | import { resetSequelizeInstance } from '../../helpers/database-utils' | |
12 | import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | |
13 | import { logger } from '../../helpers/logger' | |
e1c55031 | 14 | import { getFormattedObjects } from '../../helpers/utils' |
8054669f C |
15 | import { MIMETYPES } from '../../initializers/constants' |
16 | import { sequelizeTypescript } from '../../initializers/database' | |
8054669f | 17 | import { sendUpdateActor } from '../../lib/activitypub/send' |
8054669f | 18 | import { JobQueue } from '../../lib/job-queue' |
d0800f76 | 19 | import { deleteLocalActorImageFile, updateLocalActorImageFiles } from '../../lib/local-actor' |
8054669f | 20 | import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' |
48dce1c9 C |
21 | import { |
22 | asyncMiddleware, | |
90d4bb81 | 23 | asyncRetryTransactionMiddleware, |
06215f15 C |
24 | authenticate, |
25 | commonVideosFiltersValidator, | |
d4d9bbc6 | 26 | ensureCanManageChannelOrAccount, |
cc918ac3 | 27 | optionalAuthenticate, |
48dce1c9 C |
28 | paginationValidator, |
29 | setDefaultPagination, | |
30 | setDefaultSort, | |
8054669f | 31 | setDefaultVideosSort, |
cc918ac3 | 32 | videoChannelsAddValidator, |
cc918ac3 C |
33 | videoChannelsRemoveValidator, |
34 | videoChannelsSortValidator, | |
418d092a C |
35 | videoChannelsUpdateValidator, |
36 | videoPlaylistsSortValidator | |
48dce1c9 | 37 | } from '../../middlewares' |
4beda9e1 | 38 | import { |
2a491182 | 39 | ensureChannelOwnerCanUpload, |
a37e9e74 | 40 | ensureIsLocalChannel, |
2a491182 | 41 | videoChannelImportVideosValidator, |
4beda9e1 C |
42 | videoChannelsFollowersSortValidator, |
43 | videoChannelsListValidator, | |
44 | videoChannelsNameWithHostValidator, | |
45 | videosSortValidator | |
46 | } from '../../middlewares/validators' | |
213e30ef | 47 | import { updateAvatarValidator, updateBannerValidator } from '../../middlewares/validators/actor-image' |
8054669f | 48 | import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' |
cc918ac3 | 49 | import { AccountModel } from '../../models/account/account' |
cc918ac3 | 50 | import { VideoModel } from '../../models/video/video' |
8054669f | 51 | import { VideoChannelModel } from '../../models/video/video-channel' |
418d092a | 52 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
4bbfc6c6 | 53 | |
80e36cd9 | 54 | const auditLogger = auditLoggerFactory('channels') |
d3d3deaa C |
55 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT) |
56 | const reqBannerFile = createReqFiles([ 'bannerfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT) | |
48dce1c9 C |
57 | |
58 | const videoChannelRouter = express.Router() | |
59 | ||
60 | videoChannelRouter.get('/', | |
61 | paginationValidator, | |
62 | videoChannelsSortValidator, | |
63 | setDefaultSort, | |
64 | setDefaultPagination, | |
37a44fc9 | 65 | videoChannelsListValidator, |
48dce1c9 C |
66 | asyncMiddleware(listVideoChannels) |
67 | ) | |
68 | ||
cc918ac3 C |
69 | videoChannelRouter.post('/', |
70 | authenticate, | |
601527d7 | 71 | asyncMiddleware(videoChannelsAddValidator), |
90d4bb81 | 72 | asyncRetryTransactionMiddleware(addVideoChannel) |
cc918ac3 C |
73 | ) |
74 | ||
8a19bee1 | 75 | videoChannelRouter.post('/:nameWithHost/avatar/pick', |
4bbfc6c6 C |
76 | authenticate, |
77 | reqAvatarFile, | |
4beda9e1 | 78 | asyncMiddleware(videoChannelsNameWithHostValidator), |
a37e9e74 | 79 | ensureIsLocalChannel, |
d4d9bbc6 | 80 | ensureCanManageChannelOrAccount, |
4bbfc6c6 | 81 | updateAvatarValidator, |
4a534352 | 82 | asyncMiddleware(updateVideoChannelAvatar) |
4bbfc6c6 C |
83 | ) |
84 | ||
2cb03dc1 C |
85 | videoChannelRouter.post('/:nameWithHost/banner/pick', |
86 | authenticate, | |
87 | reqBannerFile, | |
4beda9e1 | 88 | asyncMiddleware(videoChannelsNameWithHostValidator), |
a37e9e74 | 89 | ensureIsLocalChannel, |
d4d9bbc6 | 90 | ensureCanManageChannelOrAccount, |
2cb03dc1 C |
91 | updateBannerValidator, |
92 | asyncMiddleware(updateVideoChannelBanner) | |
93 | ) | |
94 | ||
1ea7da81 RK |
95 | videoChannelRouter.delete('/:nameWithHost/avatar', |
96 | authenticate, | |
4beda9e1 | 97 | asyncMiddleware(videoChannelsNameWithHostValidator), |
a37e9e74 | 98 | ensureIsLocalChannel, |
d4d9bbc6 | 99 | ensureCanManageChannelOrAccount, |
1ea7da81 RK |
100 | asyncMiddleware(deleteVideoChannelAvatar) |
101 | ) | |
102 | ||
2cb03dc1 C |
103 | videoChannelRouter.delete('/:nameWithHost/banner', |
104 | authenticate, | |
4beda9e1 | 105 | asyncMiddleware(videoChannelsNameWithHostValidator), |
a37e9e74 | 106 | ensureIsLocalChannel, |
d4d9bbc6 | 107 | ensureCanManageChannelOrAccount, |
2cb03dc1 C |
108 | asyncMiddleware(deleteVideoChannelBanner) |
109 | ) | |
110 | ||
8a19bee1 | 111 | videoChannelRouter.put('/:nameWithHost', |
cc918ac3 | 112 | authenticate, |
4beda9e1 | 113 | asyncMiddleware(videoChannelsNameWithHostValidator), |
a37e9e74 | 114 | ensureIsLocalChannel, |
d4d9bbc6 | 115 | ensureCanManageChannelOrAccount, |
4beda9e1 | 116 | videoChannelsUpdateValidator, |
90d4bb81 | 117 | asyncRetryTransactionMiddleware(updateVideoChannel) |
cc918ac3 C |
118 | ) |
119 | ||
8a19bee1 | 120 | videoChannelRouter.delete('/:nameWithHost', |
cc918ac3 | 121 | authenticate, |
a37e9e74 | 122 | asyncMiddleware(videoChannelsNameWithHostValidator), |
123 | ensureIsLocalChannel, | |
d4d9bbc6 | 124 | ensureCanManageChannelOrAccount, |
cc918ac3 | 125 | asyncMiddleware(videoChannelsRemoveValidator), |
90d4bb81 | 126 | asyncRetryTransactionMiddleware(removeVideoChannel) |
cc918ac3 C |
127 | ) |
128 | ||
8a19bee1 C |
129 | videoChannelRouter.get('/:nameWithHost', |
130 | asyncMiddleware(videoChannelsNameWithHostValidator), | |
0260dc8a | 131 | asyncMiddleware(getVideoChannel) |
cc918ac3 C |
132 | ) |
133 | ||
418d092a C |
134 | videoChannelRouter.get('/:nameWithHost/video-playlists', |
135 | asyncMiddleware(videoChannelsNameWithHostValidator), | |
136 | paginationValidator, | |
137 | videoPlaylistsSortValidator, | |
138 | setDefaultSort, | |
139 | setDefaultPagination, | |
df0b219d | 140 | commonVideoPlaylistFiltersValidator, |
418d092a C |
141 | asyncMiddleware(listVideoChannelPlaylists) |
142 | ) | |
143 | ||
8a19bee1 C |
144 | videoChannelRouter.get('/:nameWithHost/videos', |
145 | asyncMiddleware(videoChannelsNameWithHostValidator), | |
cc918ac3 C |
146 | paginationValidator, |
147 | videosSortValidator, | |
8054669f | 148 | setDefaultVideosSort, |
cc918ac3 C |
149 | setDefaultPagination, |
150 | optionalAuthenticate, | |
d525fc39 | 151 | commonVideosFiltersValidator, |
cc918ac3 C |
152 | asyncMiddleware(listVideoChannelVideos) |
153 | ) | |
154 | ||
4beda9e1 C |
155 | videoChannelRouter.get('/:nameWithHost/followers', |
156 | authenticate, | |
157 | asyncMiddleware(videoChannelsNameWithHostValidator), | |
d4d9bbc6 | 158 | ensureCanManageChannelOrAccount, |
4beda9e1 C |
159 | paginationValidator, |
160 | videoChannelsFollowersSortValidator, | |
161 | setDefaultSort, | |
162 | setDefaultPagination, | |
163 | asyncMiddleware(listVideoChannelFollowers) | |
164 | ) | |
165 | ||
2a491182 F |
166 | videoChannelRouter.post('/:nameWithHost/import-videos', |
167 | authenticate, | |
168 | asyncMiddleware(videoChannelsNameWithHostValidator), | |
a3b472a1 | 169 | asyncMiddleware(videoChannelImportVideosValidator), |
2a491182 | 170 | ensureIsLocalChannel, |
d4d9bbc6 | 171 | ensureCanManageChannelOrAccount, |
2a491182 F |
172 | asyncMiddleware(ensureChannelOwnerCanUpload), |
173 | asyncMiddleware(importVideosInChannel) | |
174 | ) | |
175 | ||
48dce1c9 C |
176 | // --------------------------------------------------------------------------- |
177 | ||
178 | export { | |
179 | videoChannelRouter | |
180 | } | |
181 | ||
182 | // --------------------------------------------------------------------------- | |
183 | ||
dae86118 | 184 | async function listVideoChannels (req: express.Request, res: express.Response) { |
f37dc0dd | 185 | const serverActor = await getServerActor() |
0260dc8a C |
186 | |
187 | const apiOptions = await Hooks.wrapObject({ | |
bc99dfe5 RK |
188 | actorId: serverActor.id, |
189 | start: req.query.start, | |
190 | count: req.query.count, | |
4f5d0459 | 191 | sort: req.query.sort |
0260dc8a C |
192 | }, 'filter:api.video-channels.list.params') |
193 | ||
194 | const resultList = await Hooks.wrapPromiseFun( | |
195 | VideoChannelModel.listForApi, | |
196 | apiOptions, | |
197 | 'filter:api.video-channels.list.result' | |
198 | ) | |
48dce1c9 C |
199 | |
200 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | |
201 | } | |
cc918ac3 | 202 | |
2cb03dc1 C |
203 | async function updateVideoChannelBanner (req: express.Request, res: express.Response) { |
204 | const bannerPhysicalFile = req.files['bannerfile'][0] | |
205 | const videoChannel = res.locals.videoChannel | |
206 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) | |
207 | ||
d0800f76 | 208 | const banners = await updateLocalActorImageFiles(videoChannel, bannerPhysicalFile, ActorImageType.BANNER) |
2cb03dc1 C |
209 | |
210 | auditLogger.update(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys) | |
211 | ||
d0800f76 | 212 | return res.json({ |
213 | // TODO: remove, deprecated in 4.2 | |
214 | banner: getBiggestActorImage(banners).toFormattedJSON(), | |
215 | banners: banners.map(b => b.toFormattedJSON()) | |
216 | }) | |
2cb03dc1 | 217 | } |
c158a5fa | 218 | |
dae86118 | 219 | async function updateVideoChannelAvatar (req: express.Request, res: express.Response) { |
a1587156 | 220 | const avatarPhysicalFile = req.files['avatarfile'][0] |
dae86118 | 221 | const videoChannel = res.locals.videoChannel |
80e36cd9 | 222 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) |
4bbfc6c6 | 223 | |
d0800f76 | 224 | const avatars = await updateLocalActorImageFiles(videoChannel, avatarPhysicalFile, ActorImageType.AVATAR) |
f201a749 | 225 | auditLogger.update(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys) |
80e36cd9 | 226 | |
d0800f76 | 227 | return res.json({ |
228 | // TODO: remove, deprecated in 4.2 | |
229 | avatar: getBiggestActorImage(avatars).toFormattedJSON(), | |
230 | avatars: avatars.map(a => a.toFormattedJSON()) | |
231 | }) | |
4bbfc6c6 C |
232 | } |
233 | ||
1ea7da81 RK |
234 | async function deleteVideoChannelAvatar (req: express.Request, res: express.Response) { |
235 | const videoChannel = res.locals.videoChannel | |
236 | ||
2cb03dc1 C |
237 | await deleteLocalActorImageFile(videoChannel, ActorImageType.AVATAR) |
238 | ||
76148b27 | 239 | return res.status(HttpStatusCode.NO_CONTENT_204).end() |
2cb03dc1 C |
240 | } |
241 | ||
242 | async function deleteVideoChannelBanner (req: express.Request, res: express.Response) { | |
243 | const videoChannel = res.locals.videoChannel | |
244 | ||
245 | await deleteLocalActorImageFile(videoChannel, ActorImageType.BANNER) | |
1ea7da81 | 246 | |
76148b27 | 247 | return res.status(HttpStatusCode.NO_CONTENT_204).end() |
1ea7da81 RK |
248 | } |
249 | ||
cc918ac3 C |
250 | async function addVideoChannel (req: express.Request, res: express.Response) { |
251 | const videoChannelInfo: VideoChannelCreate = req.body | |
cc918ac3 | 252 | |
453e83ea | 253 | const videoChannelCreated = await sequelizeTypescript.transaction(async t => { |
dae86118 | 254 | const account = await AccountModel.load(res.locals.oauth.token.User.Account.id, t) |
91411dba | 255 | |
1ca9f7c3 | 256 | return createLocalVideoChannel(videoChannelInfo, account, t) |
cc918ac3 C |
257 | }) |
258 | ||
8795d6f2 | 259 | const payload = { actorId: videoChannelCreated.actorId } |
bd911b54 | 260 | await JobQueue.Instance.createJob({ type: 'actor-keys', payload }) |
cc918ac3 | 261 | |
91411dba | 262 | auditLogger.create(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelCreated.toFormattedJSON())) |
57cfff78 | 263 | logger.info('Video channel %s created.', videoChannelCreated.Actor.url) |
cc918ac3 | 264 | |
0260dc8a C |
265 | Hooks.runAction('action:api.video-channel.created', { videoChannel: videoChannelCreated, req, res }) |
266 | ||
90d4bb81 C |
267 | return res.json({ |
268 | videoChannel: { | |
57cfff78 | 269 | id: videoChannelCreated.id |
90d4bb81 | 270 | } |
2cb03dc1 | 271 | }) |
cc918ac3 C |
272 | } |
273 | ||
274 | async function updateVideoChannel (req: express.Request, res: express.Response) { | |
dae86118 | 275 | const videoChannelInstance = res.locals.videoChannel |
80e36cd9 | 276 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannelInstance.toFormattedJSON()) |
cc918ac3 | 277 | const videoChannelInfoToUpdate = req.body as VideoChannelUpdate |
7d14d4d2 | 278 | let doBulkVideoUpdate = false |
cc918ac3 C |
279 | |
280 | try { | |
281 | await sequelizeTypescript.transaction(async t => { | |
7d14d4d2 C |
282 | if (videoChannelInfoToUpdate.displayName !== undefined) videoChannelInstance.name = videoChannelInfoToUpdate.displayName |
283 | if (videoChannelInfoToUpdate.description !== undefined) videoChannelInstance.description = videoChannelInfoToUpdate.description | |
284 | ||
285 | if (videoChannelInfoToUpdate.support !== undefined) { | |
286 | const oldSupportField = videoChannelInstance.support | |
287 | videoChannelInstance.support = videoChannelInfoToUpdate.support | |
288 | ||
289 | if (videoChannelInfoToUpdate.bulkVideosSupportUpdate === true && oldSupportField !== videoChannelInfoToUpdate.support) { | |
290 | doBulkVideoUpdate = true | |
291 | await VideoModel.bulkUpdateSupportField(videoChannelInstance, t) | |
292 | } | |
293 | } | |
cc918ac3 | 294 | |
c158a5fa | 295 | const videoChannelInstanceUpdated = await videoChannelInstance.save({ transaction: t }) as MChannelBannerAccountDefault |
cc918ac3 | 296 | await sendUpdateActor(videoChannelInstanceUpdated, t) |
cc918ac3 | 297 | |
80e36cd9 | 298 | auditLogger.update( |
993cef4b | 299 | getAuditIdFromRes(res), |
80e36cd9 AB |
300 | new VideoChannelAuditView(videoChannelInstanceUpdated.toFormattedJSON()), |
301 | oldVideoChannelAuditKeys | |
302 | ) | |
7d14d4d2 | 303 | |
0260dc8a C |
304 | Hooks.runAction('action:api.video-channel.updated', { videoChannel: videoChannelInstanceUpdated, req, res }) |
305 | ||
57cfff78 | 306 | logger.info('Video channel %s updated.', videoChannelInstance.Actor.url) |
80e36cd9 | 307 | }) |
cc918ac3 C |
308 | } catch (err) { |
309 | logger.debug('Cannot update the video channel.', { err }) | |
310 | ||
cc918ac3 | 311 | // If the transaction is retried, sequelize will think the object has not changed |
45657746 C |
312 | // So we need to restore the previous fields |
313 | resetSequelizeInstance(videoChannelInstance) | |
cc918ac3 C |
314 | |
315 | throw err | |
316 | } | |
cc918ac3 | 317 | |
2d53be02 | 318 | res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() |
7d14d4d2 C |
319 | |
320 | // Don't process in a transaction, and after the response because it could be long | |
321 | if (doBulkVideoUpdate) { | |
322 | await federateAllVideosOfChannel(videoChannelInstance) | |
323 | } | |
cc918ac3 C |
324 | } |
325 | ||
326 | async function removeVideoChannel (req: express.Request, res: express.Response) { | |
dae86118 | 327 | const videoChannelInstance = res.locals.videoChannel |
cc918ac3 | 328 | |
90d4bb81 | 329 | await sequelizeTypescript.transaction(async t => { |
df0b219d C |
330 | await VideoPlaylistModel.resetPlaylistsOfChannel(videoChannelInstance.id, t) |
331 | ||
cc918ac3 C |
332 | await videoChannelInstance.destroy({ transaction: t }) |
333 | ||
0260dc8a C |
334 | Hooks.runAction('action:api.video-channel.deleted', { videoChannel: videoChannelInstance, req, res }) |
335 | ||
993cef4b | 336 | auditLogger.delete(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelInstance.toFormattedJSON())) |
57cfff78 | 337 | logger.info('Video channel %s deleted.', videoChannelInstance.Actor.url) |
cc918ac3 C |
338 | }) |
339 | ||
2d53be02 | 340 | return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() |
cc918ac3 C |
341 | } |
342 | ||
0260dc8a C |
343 | async function getVideoChannel (req: express.Request, res: express.Response) { |
344 | const id = res.locals.videoChannel.id | |
345 | const videoChannel = await Hooks.wrapObject(res.locals.videoChannel, 'filter:api.video-channel.get.result', { id }) | |
cc918ac3 | 346 | |
2cb03dc1 | 347 | if (videoChannel.isOutdated()) { |
bd911b54 | 348 | JobQueue.Instance.createJobAsync({ type: 'activitypub-refresher', payload: { type: 'actor', url: videoChannel.Actor.url } }) |
744d0eca C |
349 | } |
350 | ||
2cb03dc1 | 351 | return res.json(videoChannel.toFormattedJSON()) |
cc918ac3 C |
352 | } |
353 | ||
418d092a C |
354 | async function listVideoChannelPlaylists (req: express.Request, res: express.Response) { |
355 | const serverActor = await getServerActor() | |
356 | ||
357 | const resultList = await VideoPlaylistModel.listForApi({ | |
358 | followerActorId: serverActor.id, | |
359 | start: req.query.start, | |
360 | count: req.query.count, | |
361 | sort: req.query.sort, | |
df0b219d C |
362 | videoChannelId: res.locals.videoChannel.id, |
363 | type: req.query.playlistType | |
418d092a C |
364 | }) |
365 | ||
366 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | |
367 | } | |
368 | ||
dae86118 | 369 | async function listVideoChannelVideos (req: express.Request, res: express.Response) { |
2760b454 C |
370 | const serverActor = await getServerActor() |
371 | ||
dae86118 | 372 | const videoChannelInstance = res.locals.videoChannel |
2760b454 C |
373 | |
374 | const displayOnlyForFollower = isUserAbleToSearchRemoteURI(res) | |
375 | ? null | |
376 | : { | |
377 | actorId: serverActor.id, | |
378 | orLocalVideos: true | |
379 | } | |
380 | ||
fe987656 | 381 | const countVideos = getCountVideos(req) |
d6886027 | 382 | const query = pickCommonVideoQuery(req.query) |
cc918ac3 | 383 | |
38267c0c | 384 | const apiOptions = await Hooks.wrapObject({ |
d6886027 C |
385 | ...query, |
386 | ||
2760b454 | 387 | displayOnlyForFollower, |
1fd61899 | 388 | nsfw: buildNSFWFilter(res, query.nsfw), |
1cd3facc | 389 | videoChannelId: videoChannelInstance.id, |
fe987656 C |
390 | user: res.locals.oauth ? res.locals.oauth.token.User : undefined, |
391 | countVideos | |
38267c0c C |
392 | }, 'filter:api.video-channels.videos.list.params') |
393 | ||
394 | const resultList = await Hooks.wrapPromiseFun( | |
395 | VideoModel.listForApi, | |
396 | apiOptions, | |
397 | 'filter:api.video-channels.videos.list.result' | |
398 | ) | |
cc918ac3 | 399 | |
2760b454 | 400 | return res.json(getFormattedObjects(resultList.data, resultList.total, guessAdditionalAttributesFromQuery(query))) |
cc918ac3 | 401 | } |
4beda9e1 C |
402 | |
403 | async function listVideoChannelFollowers (req: express.Request, res: express.Response) { | |
404 | const channel = res.locals.videoChannel | |
405 | ||
406 | const resultList = await ActorFollowModel.listFollowersForApi({ | |
407 | actorIds: [ channel.actorId ], | |
408 | start: req.query.start, | |
409 | count: req.query.count, | |
410 | sort: req.query.sort, | |
411 | search: req.query.search, | |
906f46d0 | 412 | state: 'accepted' |
4beda9e1 C |
413 | }) |
414 | ||
415 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | |
416 | } | |
2a491182 F |
417 | |
418 | async function importVideosInChannel (req: express.Request, res: express.Response) { | |
a3b472a1 | 419 | const { externalChannelUrl } = req.body as VideosImportInChannelCreate |
2a491182 F |
420 | |
421 | await JobQueue.Instance.createJob({ | |
422 | type: 'video-channel-import', | |
423 | payload: { | |
424 | externalChannelUrl, | |
a3b472a1 C |
425 | videoChannelId: res.locals.videoChannel.id, |
426 | partOfChannelSyncId: res.locals.videoChannelSync?.id | |
2a491182 F |
427 | } |
428 | }) | |
429 | ||
430 | logger.info('Video import job for channel "%s" with url "%s" created.', res.locals.videoChannel.name, externalChannelUrl) | |
431 | ||
432 | return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() | |
433 | } |