X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fconstants.ts;h=171e9e9c2496294e07d28939ec95e74f18270250;hb=2cfd3b7eb945063242459bfb26cd654cd5938891;hp=2e9d3956ea52e88c4cefe2ce8806d004bb397eb6;hpb=ec903c010ecc54ec2acad0bf2cf10e7fbf6a0fa2;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 2e9d3956e..171e9e9c2 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -23,7 +23,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 520 +const LAST_MIGRATION_VERSION = 530 // --------------------------------------------------------------------------- @@ -55,7 +55,7 @@ const WEBSERVER = { // Sortable columns per schema const SORTABLE_COLUMNS = { - USERS: [ 'id', 'username', 'videoQuotaUsed', 'createdAt' ], + USERS: [ 'id', 'username', 'videoQuotaUsed', 'createdAt', 'lastLoginDate', 'role' ], USER_SUBSCRIPTIONS: [ 'id', 'createdAt' ], ACCOUNTS: [ 'createdAt' ], JOBS: [ 'createdAt' ], @@ -78,7 +78,7 @@ const SORTABLE_COLUMNS = { ACCOUNTS_BLOCKLIST: [ 'createdAt' ], SERVERS_BLOCKLIST: [ 'createdAt' ], - USER_NOTIFICATIONS: [ 'createdAt' ], + USER_NOTIFICATIONS: [ 'createdAt', 'read' ], VIDEO_PLAYLISTS: [ 'displayName', 'createdAt', 'updatedAt' ], @@ -206,6 +206,9 @@ const CONSTRAINTS_FIELDS = { REASON: { min: 2, max: 3000 }, // Length MODERATION_COMMENT: { min: 2, max: 3000 } // Length }, + ABUSE_MESSAGES: { + MESSAGE: { min: 2, max: 3000 } // Length + }, VIDEO_BLACKLIST: { REASON: { min: 2, max: 300 } // Length }, @@ -414,12 +417,15 @@ const MIMETYPES = { 'audio/x-ms-wma': '.wma', 'audio/wav': '.wav', 'audio/x-flac': '.flac', - 'audio/flac': '.flac' + 'audio/flac': '.flac', + '‎audio/aac': '.aac', + 'audio/ac3': '.ac3' }, EXT_MIMETYPE: null as { [ id: string ]: string } }, VIDEO: { - MIMETYPE_EXT: null as { [ id: string ]: string }, + MIMETYPE_EXT: null as { [ id: string ]: string | string[] }, + MIMETYPES_REGEX: null as string, EXT_MIMETYPE: null as { [ id: string ]: string } }, IMAGE: { @@ -539,8 +545,8 @@ const STATIC_DOWNLOAD_PATHS = { } const LAZY_STATIC_PATHS = { AVATARS: '/lazy-static/avatars/', - PREVIEWS: '/static/previews/', - VIDEO_CAPTIONS: '/static/video-captions/' + PREVIEWS: '/lazy-static/previews/', + VIDEO_CAPTIONS: '/lazy-static/video-captions/' } // Cache control @@ -820,23 +826,58 @@ export { function buildVideoMimetypeExt () { const data = { + // streamable formats that warrant cross-browser compatibility 'video/webm': '.webm', - 'video/ogg': '.ogv', + // We'll add .ogg if additional extensions are enabled + // We could add .ogg here but since it could be an audio file, + // it would be confusing for users because PeerTube will refuse their file (based on the mimetype) + 'video/ogg': [ '.ogv' ], 'video/mp4': '.mp4' } if (CONFIG.TRANSCODING.ENABLED) { if (CONFIG.TRANSCODING.ALLOW_ADDITIONAL_EXTENSIONS) { + data['video/ogg'].push('.ogg') + Object.assign(data, { - 'video/quicktime': '.mov', - 'video/x-msvideo': '.avi', - 'video/x-flv': '.flv', 'video/x-matroska': '.mkv', - 'video/avi': '.avi', + + // Developed by Apple + 'video/quicktime': [ '.mov', '.qt', '.mqv' ], // often used as output format by editing software 'video/x-m4v': '.m4v', + 'video/m4v': '.m4v', + + // Developed by the Adobe Flash Platform + 'video/x-flv': '.flv', + 'video/x-f4v': '.f4v', // replacement for flv + + // Developed by Microsoft + 'video/x-ms-wmv': '.wmv', + 'video/x-msvideo': '.avi', + 'video/avi': '.avi', + + // Developed by 3GPP + // common video formats for cell phones + 'video/3gpp': [ '.3gp', '.3gpp' ], + 'video/3gpp2': [ '.3g2', '.3gpp2' ], + + // Developed by FFmpeg/Mplayer + 'application/x-nut': '.nut', + + // The standard video format used by many Sony and Panasonic HD camcorders. + // It is also used for storing high definition video on Blu-ray discs. + 'video/mp2t': '.mts', + 'video/m2ts': '.m2ts', + + // Old formats reliant on MPEG-1/MPEG-2 + 'video/mpv': '.mpv', + 'video/mpeg2': '.m2v', + 'video/mpeg': [ '.m1v', '.mpg', '.mpe', '.mpeg', '.vob' ], + 'video/dvd': '.vob', + // Could be anything 'application/octet-stream': null, - 'video/m4v': '.m4v' + 'application/mxf': '.mxf' // often used as exchange format by editing software }) } @@ -859,14 +900,36 @@ function updateWebserverUrls () { function updateWebserverConfig () { MIMETYPES.VIDEO.MIMETYPE_EXT = buildVideoMimetypeExt() - MIMETYPES.VIDEO.EXT_MIMETYPE = invert(MIMETYPES.VIDEO.MIMETYPE_EXT) + MIMETYPES.VIDEO.MIMETYPES_REGEX = buildMimetypesRegex(MIMETYPES.VIDEO.MIMETYPE_EXT) + ACTIVITY_PUB.URL_MIME_TYPES.VIDEO = Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT) - CONSTRAINTS_FIELDS.VIDEOS.EXTNAME = buildVideosExtname() + MIMETYPES.VIDEO.EXT_MIMETYPE = buildVideoExtMimetype(MIMETYPES.VIDEO.MIMETYPE_EXT) + + CONSTRAINTS_FIELDS.VIDEOS.EXTNAME = Object.keys(MIMETYPES.VIDEO.EXT_MIMETYPE) +} + +function buildVideoExtMimetype (obj: { [ id: string ]: string | string[] }) { + const result: { [id: string]: string } = {} + + for (const mimetype of Object.keys(obj)) { + const value = obj[mimetype] + if (!value) continue + + const extensions = Array.isArray(value) ? value : [ value ] + + for (const extension of extensions) { + result[extension] = mimetype + } + } + + return result } -function buildVideosExtname () { - return Object.keys(MIMETYPES.VIDEO.EXT_MIMETYPE) +function buildMimetypesRegex (obj: { [id: string]: string | string[] }) { + return Object.keys(obj) + .map(m => `(${m})`) + .join('|') } function loadLanguages () { @@ -893,7 +956,9 @@ function buildLanguages () { jsl: true, // Japanese sign language sfs: true, // South African sign language swl: true, // Swedish sign language - rsl: true, // Russian sign language: true + rsl: true, // Russian sign language + + kab: true, // Kabyle epo: true, // Esperanto tlh: true, // Klingon