From 418d092afa81e2c8fe8ac6838fc4b5eb0af6a782 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 26 Feb 2019 10:55:40 +0100 Subject: Playlist server API --- server/initializers/constants.ts | 23 ++++++++++++++++++++++- server/initializers/database.ts | 6 +++++- 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'server/initializers') diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 0d9a6a512..154a9cffe 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -10,6 +10,7 @@ import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' import { invert } from 'lodash' import { CronRepeatOptions, EveryRepeatOptions } from 'bull' import * as bytes from 'bytes' +import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' // Use a variable to reload the configuration if we need let config: IConfig = require('config') @@ -52,7 +53,9 @@ const SORTABLE_COLUMNS = { ACCOUNTS_BLOCKLIST: [ 'createdAt' ], SERVERS_BLOCKLIST: [ 'createdAt' ], - USER_NOTIFICATIONS: [ 'createdAt' ] + USER_NOTIFICATIONS: [ 'createdAt' ], + + VIDEO_PLAYLISTS: [ 'createdAt' ] } const OAUTH_LIFETIME = { @@ -386,6 +389,17 @@ let CONSTRAINTS_FIELDS = { FILE_SIZE: { min: 10 }, URL: { min: 3, max: 2000 } // Length }, + VIDEO_PLAYLISTS: { + NAME: { min: 1, max: 120 }, // Length + DESCRIPTION: { min: 3, max: 1000 }, // Length + URL: { min: 3, max: 2000 }, // Length + IMAGE: { + EXTNAME: [ '.jpg', '.jpeg' ], + FILE_SIZE: { + max: 2 * 1024 * 1024 // 2MB + } + } + }, ACTORS: { PUBLIC_KEY: { min: 10, max: 5000 }, // Length PRIVATE_KEY: { min: 10, max: 5000 }, // Length @@ -502,6 +516,12 @@ const VIDEO_ABUSE_STATES = { [VideoAbuseState.ACCEPTED]: 'Accepted' } +const VIDEO_PLAYLIST_PRIVACIES = { + [VideoPlaylistPrivacy.PUBLIC]: 'Public', + [VideoPlaylistPrivacy.UNLISTED]: 'Unlisted', + [VideoPlaylistPrivacy.PRIVATE]: 'Private' +} + const MIMETYPES = { VIDEO: { MIMETYPE_EXT: buildVideoMimetypeExt(), @@ -786,6 +806,7 @@ export { VIDEO_IMPORT_STATES, VIDEO_VIEW_LIFETIME, CONTACT_FORM_LIFETIME, + VIDEO_PLAYLIST_PRIVACIES, buildLanguages } diff --git a/server/initializers/database.ts b/server/initializers/database.ts index fe296142d..541ebbecf 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts @@ -34,6 +34,8 @@ import { ServerBlocklistModel } from '../models/server/server-blocklist' import { UserNotificationModel } from '../models/account/user-notification' import { UserNotificationSettingModel } from '../models/account/user-notification-setting' import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' +import { VideoPlaylistModel } from '../models/video/video-playlist' +import { VideoPlaylistElementModel } from '../models/video/video-playlist-element' require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string @@ -101,7 +103,9 @@ async function initDatabaseModels (silent: boolean) { ServerBlocklistModel, UserNotificationModel, UserNotificationSettingModel, - VideoStreamingPlaylistModel + VideoStreamingPlaylistModel, + VideoPlaylistModel, + VideoPlaylistElementModel ]) // Check extensions exist in the database -- cgit v1.2.3