mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00

* Add external channel URL for channel update / creation (#754) * Disallow synchronisation if user has no video quota (#754) * More constraints serverside (#754) * Disable sync if server configuration does not allow HTTP import (#754) * Working version synchronizing videos with a job (#754) TODO: refactoring, too much code duplication * More logs and try/catch (#754) * Fix eslint error (#754) * WIP: support synchronization time change (#754) * New frontend #754 * WIP: Create sync front (#754) * Enhance UI, sync creation form (#754) * Warning message when HTTP upload is disallowed * More consistent names (#754) * Binding Front with API (#754) * Add a /me API (#754) * Improve list UI (#754) * Implement creation and deletion routes (#754) * Lint (#754) * Lint again (#754) * WIP: UI for triggering import existing videos (#754) * Implement jobs for syncing and importing channels * Don't sync videos before sync creation + avoid concurrency issue (#754) * Cleanup (#754) * Cleanup: OpenAPI + API rework (#754) * Remove dead code (#754) * Eslint (#754) * Revert the mess with whitespaces in constants.ts (#754) * Some fixes after rebase (#754) * Several fixes after PR remarks (#754) * Front + API: Rename video-channels-sync to video-channel-syncs (#754) * Allow enabling channel sync through UI (#754) * getChannelInfo (#754) * Minor fixes: openapi + model + sql (#754) * Simplified API validators (#754) * Rename MChannelSync to MChannelSyncChannel (#754) * Add command for VideoChannelSync (#754) * Use synchronization.enabled config (#754) * Check parameters test + some fixes (#754) * Fix conflict mistake (#754) * Restrict access to video channel sync list API (#754) * Start adding unit test for synchronization (#754) * Continue testing (#754) * Tests finished + convertion of job to scheduler (#754) * Add lastSyncAt field (#754) * Fix externalRemoteUrl sort + creation date not well formatted (#754) * Small fix (#754) * Factorize addYoutubeDLImport and buildVideo (#754) * Check duplicates on channel not on users (#754) * factorize thumbnail generation (#754) * Fetch error should return status 400 (#754) * Separate video-channel-import and video-channel-sync-latest (#754) * Bump DB migration version after rebase (#754) * Prettier states in UI table (#754) * Add DefaultScope in VideoChannelSyncModel (#754) * Fix audit logs (#754) * Ensure user can upload when importing channel + minor fixes (#754) * Mark synchronization as failed on exception + typos (#754) * Change REST API for importing videos into channel (#754) * Add option for fully synchronize a chnanel (#754) * Return a whole sync object on creation to avoid tricks in Front (#754) * Various remarks (#754) * Single quotes by default (#754) * Rename synchronization to video_channel_synchronization * Add check.latest_videos_count and max_per_user options (#754) * Better channel rendering in list #754 * Allow sorting with channel name and state (#754) * Add missing tests for channel imports (#754) * Prefer using a parent job for channel sync * Styling * Client styling Co-authored-by: Chocobozzz <me@florianbigard.com>
90 lines
4.2 KiB
TypeScript
90 lines
4.2 KiB
TypeScript
import express from 'express'
|
|
import { query } from 'express-validator'
|
|
import { logger } from '@server/helpers/logger'
|
|
import { SORTABLE_COLUMNS } from '../../initializers/constants'
|
|
import { areValidationErrors } from './shared'
|
|
|
|
function checkSortFactory (columns: string[], tags: string[] = []) {
|
|
return checkSort(createSortableColumns(columns), tags)
|
|
}
|
|
|
|
function checkSort (sortableColumns: string[], tags: string[] = []) {
|
|
return [
|
|
query('sort').optional().isIn(sortableColumns).withMessage('Should have correct sortable column'),
|
|
|
|
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
|
logger.debug('Checking sort parameters', { parameters: req.query, tags })
|
|
|
|
if (areValidationErrors(req, res)) return
|
|
|
|
return next()
|
|
}
|
|
]
|
|
}
|
|
|
|
function createSortableColumns (sortableColumns: string[]) {
|
|
const sortableColumnDesc = sortableColumns.map(sortableColumn => '-' + sortableColumn)
|
|
|
|
return sortableColumns.concat(sortableColumnDesc)
|
|
}
|
|
|
|
const adminUsersSortValidator = checkSortFactory(SORTABLE_COLUMNS.ADMIN_USERS)
|
|
const accountsSortValidator = checkSortFactory(SORTABLE_COLUMNS.ACCOUNTS)
|
|
const jobsSortValidator = checkSortFactory(SORTABLE_COLUMNS.JOBS, [ 'jobs' ])
|
|
const abusesSortValidator = checkSortFactory(SORTABLE_COLUMNS.ABUSES)
|
|
const videosSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEOS)
|
|
const videoImportsSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEO_IMPORTS)
|
|
const videosSearchSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEOS_SEARCH)
|
|
const videoChannelsSearchSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEO_CHANNELS_SEARCH)
|
|
const videoPlaylistsSearchSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEO_PLAYLISTS_SEARCH)
|
|
const videoCommentsValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEO_COMMENTS)
|
|
const videoCommentThreadsSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS)
|
|
const videoRatesSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEO_RATES)
|
|
const blacklistSortValidator = checkSortFactory(SORTABLE_COLUMNS.BLACKLISTS)
|
|
const videoChannelsSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEO_CHANNELS)
|
|
const instanceFollowersSortValidator = checkSortFactory(SORTABLE_COLUMNS.INSTANCE_FOLLOWERS)
|
|
const instanceFollowingSortValidator = checkSortFactory(SORTABLE_COLUMNS.INSTANCE_FOLLOWING)
|
|
const userSubscriptionsSortValidator = checkSortFactory(SORTABLE_COLUMNS.USER_SUBSCRIPTIONS)
|
|
const accountsBlocklistSortValidator = checkSortFactory(SORTABLE_COLUMNS.ACCOUNTS_BLOCKLIST)
|
|
const serversBlocklistSortValidator = checkSortFactory(SORTABLE_COLUMNS.SERVERS_BLOCKLIST)
|
|
const userNotificationsSortValidator = checkSortFactory(SORTABLE_COLUMNS.USER_NOTIFICATIONS)
|
|
const videoPlaylistsSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEO_PLAYLISTS)
|
|
const pluginsSortValidator = checkSortFactory(SORTABLE_COLUMNS.PLUGINS)
|
|
const availablePluginsSortValidator = checkSortFactory(SORTABLE_COLUMNS.AVAILABLE_PLUGINS)
|
|
const videoRedundanciesSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEO_REDUNDANCIES)
|
|
const videoChannelSyncsSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEO_CHANNEL_SYNCS)
|
|
|
|
const accountsFollowersSortValidator = checkSortFactory(SORTABLE_COLUMNS.ACCOUNT_FOLLOWERS)
|
|
const videoChannelsFollowersSortValidator = checkSortFactory(SORTABLE_COLUMNS.CHANNEL_FOLLOWERS)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
export {
|
|
adminUsersSortValidator,
|
|
abusesSortValidator,
|
|
videoChannelsSortValidator,
|
|
videoImportsSortValidator,
|
|
videoCommentsValidator,
|
|
videosSearchSortValidator,
|
|
videosSortValidator,
|
|
blacklistSortValidator,
|
|
accountsSortValidator,
|
|
instanceFollowersSortValidator,
|
|
instanceFollowingSortValidator,
|
|
jobsSortValidator,
|
|
videoCommentThreadsSortValidator,
|
|
videoRatesSortValidator,
|
|
userSubscriptionsSortValidator,
|
|
availablePluginsSortValidator,
|
|
videoChannelsSearchSortValidator,
|
|
accountsBlocklistSortValidator,
|
|
serversBlocklistSortValidator,
|
|
userNotificationsSortValidator,
|
|
videoPlaylistsSortValidator,
|
|
videoRedundanciesSortValidator,
|
|
videoPlaylistsSearchSortValidator,
|
|
accountsFollowersSortValidator,
|
|
videoChannelsFollowersSortValidator,
|
|
videoChannelSyncsSortValidator,
|
|
pluginsSortValidator
|
|
}
|