From a3b472a12ec6e57dbe2f650419f8064864686eab Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 10 Aug 2022 11:51:13 +0200 Subject: Add ability to list imports of a channel sync --- server/controllers/api/users/me.ts | 11 +++++++++-- server/controllers/api/video-channel.ts | 9 +++++---- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 595abcf95..00f580ee9 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts @@ -25,7 +25,13 @@ import { usersUpdateMeValidator, usersVideoRatingValidator } from '../../../middlewares' -import { deleteMeValidator, usersVideosValidator, videoImportsSortValidator, videosSortValidator } from '../../../middlewares/validators' +import { + deleteMeValidator, + getMyVideoImportsValidator, + usersVideosValidator, + videoImportsSortValidator, + videosSortValidator +} from '../../../middlewares/validators' import { updateAvatarValidator } from '../../../middlewares/validators/actor-image' import { AccountModel } from '../../../models/account/account' import { AccountVideoRateModel } from '../../../models/account/account-video-rate' @@ -60,6 +66,7 @@ meRouter.get('/me/videos/imports', videoImportsSortValidator, setDefaultSort, setDefaultPagination, + getMyVideoImportsValidator, asyncMiddleware(getUserVideoImports) ) @@ -138,7 +145,7 @@ async function getUserVideoImports (req: express.Request, res: express.Response) const resultList = await VideoImportModel.listUserVideoImportsForApi({ userId: user.id, - ...pick(req.query, [ 'targetUrl', 'start', 'count', 'sort' ]) + ...pick(req.query, [ 'targetUrl', 'start', 'count', 'sort', 'search', 'videoChannelSyncId' ]) }) return res.json(getFormattedObjects(resultList.data, resultList.total)) diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index 89c7181bd..94285a78d 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts @@ -6,7 +6,7 @@ import { ActorFollowModel } from '@server/models/actor/actor-follow' import { getServerActor } from '@server/models/application/application' import { guessAdditionalAttributesFromQuery } from '@server/models/video/formatter/video-format-utils' import { MChannelBannerAccountDefault } from '@server/types/models' -import { ActorImageType, HttpStatusCode, VideoChannelCreate, VideoChannelUpdate } from '@shared/models' +import { ActorImageType, HttpStatusCode, VideoChannelCreate, VideoChannelUpdate, VideosImportInChannelCreate } from '@shared/models' import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' import { resetSequelizeInstance } from '../../helpers/database-utils' import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' @@ -166,7 +166,7 @@ videoChannelRouter.get('/:nameWithHost/followers', videoChannelRouter.post('/:nameWithHost/import-videos', authenticate, asyncMiddleware(videoChannelsNameWithHostValidator), - videoChannelImportVideosValidator, + asyncMiddleware(videoChannelImportVideosValidator), ensureIsLocalChannel, ensureCanManageChannel, asyncMiddleware(ensureChannelOwnerCanUpload), @@ -418,13 +418,14 @@ async function listVideoChannelFollowers (req: express.Request, res: express.Res } async function importVideosInChannel (req: express.Request, res: express.Response) { - const { externalChannelUrl } = req.body + const { externalChannelUrl } = req.body as VideosImportInChannelCreate await JobQueue.Instance.createJob({ type: 'video-channel-import', payload: { externalChannelUrl, - videoChannelId: res.locals.videoChannel.id + videoChannelId: res.locals.videoChannel.id, + partOfChannelSyncId: res.locals.videoChannelSync?.id } }) -- cgit v1.2.3