aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/config.ts5
-rw-r--r--server/controllers/api/users/me.ts4
-rw-r--r--server/controllers/api/video-channel.ts4
-rw-r--r--server/controllers/api/videos/captions.ts4
-rw-r--r--server/controllers/api/videos/import.ts11
-rw-r--r--server/controllers/api/videos/index.ts12
6 files changed, 17 insertions, 23 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index d65e321e9..c75002aaf 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -172,7 +172,8 @@ async function updateCustomConfig (req: express.Request, res: express.Response,
172 'instance.defaultClientRoute', 172 'instance.defaultClientRoute',
173 'instance.shortDescription', 173 'instance.shortDescription',
174 'cache.videoCaptions', 174 'cache.videoCaptions',
175 'signup.requiresEmailVerification' 175 'signup.requiresEmailVerification',
176 'transcoding.allowAdditionalExtensions'
176 ) 177 )
177 toUpdateJSON.user['video_quota'] = toUpdate.user.videoQuota 178 toUpdateJSON.user['video_quota'] = toUpdate.user.videoQuota
178 toUpdateJSON.user['video_quota_daily'] = toUpdate.user.videoQuotaDaily 179 toUpdateJSON.user['video_quota_daily'] = toUpdate.user.videoQuotaDaily
@@ -180,6 +181,7 @@ async function updateCustomConfig (req: express.Request, res: express.Response,
180 toUpdateJSON.instance['short_description'] = toUpdate.instance.shortDescription 181 toUpdateJSON.instance['short_description'] = toUpdate.instance.shortDescription
181 toUpdateJSON.instance['default_nsfw_policy'] = toUpdate.instance.defaultNSFWPolicy 182 toUpdateJSON.instance['default_nsfw_policy'] = toUpdate.instance.defaultNSFWPolicy
182 toUpdateJSON.signup['requires_email_verification'] = toUpdate.signup.requiresEmailVerification 183 toUpdateJSON.signup['requires_email_verification'] = toUpdate.signup.requiresEmailVerification
184 toUpdateJSON.transcoding['allow_additional_extensions'] = toUpdate.transcoding.allowAdditionalExtensions
183 185
184 await writeJSON(CONFIG.CUSTOM_FILE, toUpdateJSON, { spaces: 2 }) 186 await writeJSON(CONFIG.CUSTOM_FILE, toUpdateJSON, { spaces: 2 })
185 187
@@ -247,6 +249,7 @@ function customConfig (): CustomConfig {
247 }, 249 },
248 transcoding: { 250 transcoding: {
249 enabled: CONFIG.TRANSCODING.ENABLED, 251 enabled: CONFIG.TRANSCODING.ENABLED,
252 allowAdditionalExtensions: CONFIG.TRANSCODING.ALLOW_ADDITIONAL_EXTENSIONS,
250 threads: CONFIG.TRANSCODING.THREADS, 253 threads: CONFIG.TRANSCODING.THREADS,
251 resolutions: { 254 resolutions: {
252 '240p': CONFIG.TRANSCODING.RESOLUTIONS[ '240p' ], 255 '240p': CONFIG.TRANSCODING.RESOLUTIONS[ '240p' ],
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts
index d2456346b..f712b0f0b 100644
--- a/server/controllers/api/users/me.ts
+++ b/server/controllers/api/users/me.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import 'multer' 2import 'multer'
3import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared' 3import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared'
4import { getFormattedObjects } from '../../../helpers/utils' 4import { getFormattedObjects } from '../../../helpers/utils'
5import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../../initializers' 5import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers'
6import { sendUpdateActor } from '../../../lib/activitypub/send' 6import { sendUpdateActor } from '../../../lib/activitypub/send'
7import { 7import {
8 asyncMiddleware, 8 asyncMiddleware,
@@ -42,7 +42,7 @@ import { AccountModel } from '../../../models/account/account'
42 42
43const auditLogger = auditLoggerFactory('users-me') 43const auditLogger = auditLoggerFactory('users-me')
44 44
45const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) 45const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR })
46 46
47const meRouter = express.Router() 47const meRouter = express.Router()
48 48
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index fd143a139..3d6a6af7f 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -22,7 +22,7 @@ import { createVideoChannel } from '../../lib/video-channel'
22import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' 22import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
23import { setAsyncActorKeys } from '../../lib/activitypub' 23import { setAsyncActorKeys } from '../../lib/activitypub'
24import { AccountModel } from '../../models/account/account' 24import { AccountModel } from '../../models/account/account'
25import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../initializers' 25import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../initializers'
26import { logger } from '../../helpers/logger' 26import { logger } from '../../helpers/logger'
27import { VideoModel } from '../../models/video/video' 27import { VideoModel } from '../../models/video/video'
28import { updateAvatarValidator } from '../../middlewares/validators/avatar' 28import { updateAvatarValidator } from '../../middlewares/validators/avatar'
@@ -32,7 +32,7 @@ import { resetSequelizeInstance } from '../../helpers/database-utils'
32import { UserModel } from '../../models/account/user' 32import { UserModel } from '../../models/account/user'
33 33
34const auditLogger = auditLoggerFactory('channels') 34const auditLogger = auditLoggerFactory('channels')
35const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) 35const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR })
36 36
37const videoChannelRouter = express.Router() 37const videoChannelRouter = express.Router()
38 38
diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts
index 3ba918189..9b3661368 100644
--- a/server/controllers/api/videos/captions.ts
+++ b/server/controllers/api/videos/captions.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' 2import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares'
3import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators' 3import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators'
4import { createReqFiles } from '../../../helpers/express-utils' 4import { createReqFiles } from '../../../helpers/express-utils'
5import { CONFIG, sequelizeTypescript, VIDEO_CAPTIONS_MIMETYPE_EXT } from '../../../initializers' 5import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers'
6import { getFormattedObjects } from '../../../helpers/utils' 6import { getFormattedObjects } from '../../../helpers/utils'
7import { VideoCaptionModel } from '../../../models/video/video-caption' 7import { VideoCaptionModel } from '../../../models/video/video-caption'
8import { VideoModel } from '../../../models/video/video' 8import { VideoModel } from '../../../models/video/video'
@@ -12,7 +12,7 @@ import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
12 12
13const reqVideoCaptionAdd = createReqFiles( 13const reqVideoCaptionAdd = createReqFiles(
14 [ 'captionfile' ], 14 [ 'captionfile' ],
15 VIDEO_CAPTIONS_MIMETYPE_EXT, 15 MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT,
16 { 16 {
17 captionfile: CONFIG.STORAGE.CAPTIONS_DIR 17 captionfile: CONFIG.STORAGE.CAPTIONS_DIR
18 } 18 }
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index f27d648c7..099ab7b8d 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -3,14 +3,7 @@ import * as magnetUtil from 'magnet-uri'
3import 'multer' 3import 'multer'
4import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' 4import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger'
5import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' 5import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares'
6import { 6import { CONFIG, MIMETYPES, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers'
7 CONFIG,
8 IMAGE_MIMETYPE_EXT,
9 PREVIEWS_SIZE,
10 sequelizeTypescript,
11 THUMBNAILS_SIZE,
12 TORRENT_MIMETYPE_EXT
13} from '../../../initializers'
14import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl' 7import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl'
15import { createReqFiles } from '../../../helpers/express-utils' 8import { createReqFiles } from '../../../helpers/express-utils'
16import { logger } from '../../../helpers/logger' 9import { logger } from '../../../helpers/logger'
@@ -35,7 +28,7 @@ const videoImportsRouter = express.Router()
35 28
36const reqVideoFileImport = createReqFiles( 29const reqVideoFileImport = createReqFiles(
37 [ 'thumbnailfile', 'previewfile', 'torrentfile' ], 30 [ 'thumbnailfile', 'previewfile', 'torrentfile' ],
38 Object.assign({}, TORRENT_MIMETYPE_EXT, IMAGE_MIMETYPE_EXT), 31 Object.assign({}, MIMETYPES.TORRENT.MIMETYPE_EXT, MIMETYPES.IMAGE.MIMETYPE_EXT),
39 { 32 {
40 thumbnailfile: CONFIG.STORAGE.TMP_DIR, 33 thumbnailfile: CONFIG.STORAGE.TMP_DIR,
41 previewfile: CONFIG.STORAGE.TMP_DIR, 34 previewfile: CONFIG.STORAGE.TMP_DIR,
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 4e4697ef4..00a1302d1 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -7,15 +7,13 @@ import { logger } from '../../../helpers/logger'
7import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' 7import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
8import { getFormattedObjects, getServerActor } from '../../../helpers/utils' 8import { getFormattedObjects, getServerActor } from '../../../helpers/utils'
9import { 9import {
10 CONFIG, 10 CONFIG, MIMETYPES,
11 IMAGE_MIMETYPE_EXT,
12 PREVIEWS_SIZE, 11 PREVIEWS_SIZE,
13 sequelizeTypescript, 12 sequelizeTypescript,
14 THUMBNAILS_SIZE, 13 THUMBNAILS_SIZE,
15 VIDEO_CATEGORIES, 14 VIDEO_CATEGORIES,
16 VIDEO_LANGUAGES, 15 VIDEO_LANGUAGES,
17 VIDEO_LICENCES, 16 VIDEO_LICENCES,
18 VIDEO_MIMETYPE_EXT,
19 VIDEO_PRIVACIES 17 VIDEO_PRIVACIES
20} from '../../../initializers' 18} from '../../../initializers'
21import { 19import {
@@ -57,7 +55,7 @@ import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-u
57import { videoCaptionsRouter } from './captions' 55import { videoCaptionsRouter } from './captions'
58import { videoImportsRouter } from './import' 56import { videoImportsRouter } from './import'
59import { resetSequelizeInstance } from '../../../helpers/database-utils' 57import { resetSequelizeInstance } from '../../../helpers/database-utils'
60import { rename } from 'fs-extra' 58import { move } from 'fs-extra'
61import { watchingRouter } from './watching' 59import { watchingRouter } from './watching'
62 60
63const auditLogger = auditLoggerFactory('videos') 61const auditLogger = auditLoggerFactory('videos')
@@ -65,7 +63,7 @@ const videosRouter = express.Router()
65 63
66const reqVideoFileAdd = createReqFiles( 64const reqVideoFileAdd = createReqFiles(
67 [ 'videofile', 'thumbnailfile', 'previewfile' ], 65 [ 'videofile', 'thumbnailfile', 'previewfile' ],
68 Object.assign({}, VIDEO_MIMETYPE_EXT, IMAGE_MIMETYPE_EXT), 66 Object.assign({}, MIMETYPES.VIDEO.MIMETYPE_EXT, MIMETYPES.IMAGE.MIMETYPE_EXT),
69 { 67 {
70 videofile: CONFIG.STORAGE.TMP_DIR, 68 videofile: CONFIG.STORAGE.TMP_DIR,
71 thumbnailfile: CONFIG.STORAGE.TMP_DIR, 69 thumbnailfile: CONFIG.STORAGE.TMP_DIR,
@@ -74,7 +72,7 @@ const reqVideoFileAdd = createReqFiles(
74) 72)
75const reqVideoFileUpdate = createReqFiles( 73const reqVideoFileUpdate = createReqFiles(
76 [ 'thumbnailfile', 'previewfile' ], 74 [ 'thumbnailfile', 'previewfile' ],
77 IMAGE_MIMETYPE_EXT, 75 MIMETYPES.IMAGE.MIMETYPE_EXT,
78 { 76 {
79 thumbnailfile: CONFIG.STORAGE.TMP_DIR, 77 thumbnailfile: CONFIG.STORAGE.TMP_DIR,
80 previewfile: CONFIG.STORAGE.TMP_DIR 78 previewfile: CONFIG.STORAGE.TMP_DIR
@@ -208,7 +206,7 @@ async function addVideo (req: express.Request, res: express.Response) {
208 // Move physical file 206 // Move physical file
209 const videoDir = CONFIG.STORAGE.VIDEOS_DIR 207 const videoDir = CONFIG.STORAGE.VIDEOS_DIR
210 const destination = join(videoDir, video.getVideoFilename(videoFile)) 208 const destination = join(videoDir, video.getVideoFilename(videoFile))
211 await rename(videoPhysicalFile.path, destination) 209 await move(videoPhysicalFile.path, destination)
212 // This is important in case if there is another attempt in the retry process 210 // This is important in case if there is another attempt in the retry process
213 videoPhysicalFile.filename = video.getVideoFilename(videoFile) 211 videoPhysicalFile.filename = video.getVideoFilename(videoFile)
214 videoPhysicalFile.path = destination 212 videoPhysicalFile.path = destination