diff options
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/activitypub/client.ts | 15 | ||||
-rw-r--r-- | server/controllers/api/accounts.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/config.ts | 3 | ||||
-rw-r--r-- | server/controllers/api/users/index.ts | 37 | ||||
-rw-r--r-- | server/controllers/api/users/me.ts | 21 | ||||
-rw-r--r-- | server/controllers/api/users/my-notifications.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/video-channel.ts | 25 | ||||
-rw-r--r-- | server/controllers/api/video-playlist.ts | 12 | ||||
-rw-r--r-- | server/controllers/api/videos/captions.ts | 11 | ||||
-rw-r--r-- | server/controllers/api/videos/editor.ts | 118 | ||||
-rw-r--r-- | server/controllers/api/videos/import.ts | 7 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/videos/live.ts | 10 | ||||
-rw-r--r-- | server/controllers/api/videos/transcoding.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/videos/update.ts | 10 | ||||
-rw-r--r-- | server/controllers/api/videos/upload.ts | 21 | ||||
-rw-r--r-- | server/controllers/client.ts | 4 | ||||
-rw-r--r-- | server/controllers/lazy-static.ts | 10 |
18 files changed, 210 insertions, 104 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index 4e6bd5e25..c4d1be121 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -18,10 +18,10 @@ import { | |||
18 | } from '../../lib/activitypub/url' | 18 | } from '../../lib/activitypub/url' |
19 | import { | 19 | import { |
20 | asyncMiddleware, | 20 | asyncMiddleware, |
21 | ensureIsLocalChannel, | ||
21 | executeIfActivityPub, | 22 | executeIfActivityPub, |
22 | localAccountValidator, | 23 | localAccountValidator, |
23 | videoChannelsNameWithHostValidator, | 24 | videoChannelsNameWithHostValidator, |
24 | ensureIsLocalChannel, | ||
25 | videosCustomGetValidator, | 25 | videosCustomGetValidator, |
26 | videosShareValidator | 26 | videosShareValidator |
27 | } from '../../middlewares' | 27 | } from '../../middlewares' |
@@ -265,8 +265,8 @@ async function videoAnnouncesController (req: express.Request, res: express.Resp | |||
265 | const handler = async (start: number, count: number) => { | 265 | const handler = async (start: number, count: number) => { |
266 | const result = await VideoShareModel.listAndCountByVideoId(video.id, start, count) | 266 | const result = await VideoShareModel.listAndCountByVideoId(video.id, start, count) |
267 | return { | 267 | return { |
268 | total: result.count, | 268 | total: result.total, |
269 | data: result.rows.map(r => r.url) | 269 | data: result.data.map(r => r.url) |
270 | } | 270 | } |
271 | } | 271 | } |
272 | const json = await activityPubCollectionPagination(getLocalVideoSharesActivityPubUrl(video), handler, req.query.page) | 272 | const json = await activityPubCollectionPagination(getLocalVideoSharesActivityPubUrl(video), handler, req.query.page) |
@@ -301,9 +301,10 @@ async function videoCommentsController (req: express.Request, res: express.Respo | |||
301 | 301 | ||
302 | const handler = async (start: number, count: number) => { | 302 | const handler = async (start: number, count: number) => { |
303 | const result = await VideoCommentModel.listAndCountByVideoForAP(video, start, count) | 303 | const result = await VideoCommentModel.listAndCountByVideoForAP(video, start, count) |
304 | |||
304 | return { | 305 | return { |
305 | total: result.count, | 306 | total: result.total, |
306 | data: result.rows.map(r => r.url) | 307 | data: result.data.map(r => r.url) |
307 | } | 308 | } |
308 | } | 309 | } |
309 | const json = await activityPubCollectionPagination(getLocalVideoCommentsActivityPubUrl(video), handler, req.query.page) | 310 | const json = await activityPubCollectionPagination(getLocalVideoCommentsActivityPubUrl(video), handler, req.query.page) |
@@ -425,8 +426,8 @@ function videoRates (req: express.Request, rateType: VideoRateType, video: MVide | |||
425 | const handler = async (start: number, count: number) => { | 426 | const handler = async (start: number, count: number) => { |
426 | const result = await AccountVideoRateModel.listAndCountAccountUrlsByVideoId(rateType, video.id, start, count) | 427 | const result = await AccountVideoRateModel.listAndCountAccountUrlsByVideoId(rateType, video.id, start, count) |
427 | return { | 428 | return { |
428 | total: result.count, | 429 | total: result.total, |
429 | data: result.rows.map(r => r.url) | 430 | data: result.data.map(r => r.url) |
430 | } | 431 | } |
431 | } | 432 | } |
432 | return activityPubCollectionPagination(url, handler, req.query.page) | 433 | return activityPubCollectionPagination(url, handler, req.query.page) |
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts index 46d89bafa..8d9f92d93 100644 --- a/server/controllers/api/accounts.ts +++ b/server/controllers/api/accounts.ts | |||
@@ -213,7 +213,7 @@ async function listAccountRatings (req: express.Request, res: express.Response) | |||
213 | sort: req.query.sort, | 213 | sort: req.query.sort, |
214 | type: req.query.rating | 214 | type: req.query.rating |
215 | }) | 215 | }) |
216 | return res.json(getFormattedObjects(resultList.rows, resultList.count)) | 216 | return res.json(getFormattedObjects(resultList.data, resultList.total)) |
217 | } | 217 | } |
218 | 218 | ||
219 | async function listAccountFollowers (req: express.Request, res: express.Response) { | 219 | async function listAccountFollowers (req: express.Request, res: express.Response) { |
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 4e3dd4d80..821ed4ad3 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -256,6 +256,9 @@ function customConfig (): CustomConfig { | |||
256 | } | 256 | } |
257 | } | 257 | } |
258 | }, | 258 | }, |
259 | videoEditor: { | ||
260 | enabled: CONFIG.VIDEO_EDITOR.ENABLED | ||
261 | }, | ||
259 | import: { | 262 | import: { |
260 | videos: { | 263 | videos: { |
261 | concurrency: CONFIG.IMPORT.VIDEOS.CONCURRENCY, | 264 | concurrency: CONFIG.IMPORT.VIDEOS.CONCURRENCY, |
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index 7efc3a137..8a06bfe93 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts | |||
@@ -3,8 +3,9 @@ import RateLimit from 'express-rate-limit' | |||
3 | import { tokensRouter } from '@server/controllers/api/users/token' | 3 | import { tokensRouter } from '@server/controllers/api/users/token' |
4 | import { Hooks } from '@server/lib/plugins/hooks' | 4 | import { Hooks } from '@server/lib/plugins/hooks' |
5 | import { OAuthTokenModel } from '@server/models/oauth/oauth-token' | 5 | import { OAuthTokenModel } from '@server/models/oauth/oauth-token' |
6 | import { MUser, MUserAccountDefault } from '@server/types/models' | 6 | import { MUserAccountDefault } from '@server/types/models' |
7 | import { HttpStatusCode, UserAdminFlag, UserCreate, UserCreateResult, UserRegister, UserRight, UserRole, UserUpdate } from '@shared/models' | 7 | import { pick } from '@shared/core-utils' |
8 | import { HttpStatusCode, UserCreate, UserCreateResult, UserRegister, UserRight, UserUpdate } from '@shared/models' | ||
8 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' | 9 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' |
9 | import { logger } from '../../../helpers/logger' | 10 | import { logger } from '../../../helpers/logger' |
10 | import { generateRandomString, getFormattedObjects } from '../../../helpers/utils' | 11 | import { generateRandomString, getFormattedObjects } from '../../../helpers/utils' |
@@ -14,7 +15,7 @@ import { sequelizeTypescript } from '../../../initializers/database' | |||
14 | import { Emailer } from '../../../lib/emailer' | 15 | import { Emailer } from '../../../lib/emailer' |
15 | import { Notifier } from '../../../lib/notifier' | 16 | import { Notifier } from '../../../lib/notifier' |
16 | import { Redis } from '../../../lib/redis' | 17 | import { Redis } from '../../../lib/redis' |
17 | import { createUserAccountAndChannelAndPlaylist, sendVerifyUserEmail } from '../../../lib/user' | 18 | import { buildUser, createUserAccountAndChannelAndPlaylist, sendVerifyUserEmail } from '../../../lib/user' |
18 | import { | 19 | import { |
19 | asyncMiddleware, | 20 | asyncMiddleware, |
20 | asyncRetryTransactionMiddleware, | 21 | asyncRetryTransactionMiddleware, |
@@ -175,18 +176,11 @@ export { | |||
175 | async function createUser (req: express.Request, res: express.Response) { | 176 | async function createUser (req: express.Request, res: express.Response) { |
176 | const body: UserCreate = req.body | 177 | const body: UserCreate = req.body |
177 | 178 | ||
178 | const userToCreate = new UserModel({ | 179 | const userToCreate = buildUser({ |
179 | username: body.username, | 180 | ...pick(body, [ 'username', 'password', 'email', 'role', 'videoQuota', 'videoQuotaDaily', 'adminFlags' ]), |
180 | password: body.password, | 181 | |
181 | email: body.email, | 182 | emailVerified: null |
182 | nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, | 183 | }) |
183 | p2pEnabled: CONFIG.DEFAULTS.P2P.WEBAPP.ENABLED, | ||
184 | autoPlayVideo: true, | ||
185 | role: body.role, | ||
186 | videoQuota: body.videoQuota, | ||
187 | videoQuotaDaily: body.videoQuotaDaily, | ||
188 | adminFlags: body.adminFlags || UserAdminFlag.NONE | ||
189 | }) as MUser | ||
190 | 184 | ||
191 | // NB: due to the validator usersAddValidator, password==='' can only be true if we can send the mail. | 185 | // NB: due to the validator usersAddValidator, password==='' can only be true if we can send the mail. |
192 | const createPassword = userToCreate.password === '' | 186 | const createPassword = userToCreate.password === '' |
@@ -225,16 +219,9 @@ async function createUser (req: express.Request, res: express.Response) { | |||
225 | async function registerUser (req: express.Request, res: express.Response) { | 219 | async function registerUser (req: express.Request, res: express.Response) { |
226 | const body: UserRegister = req.body | 220 | const body: UserRegister = req.body |
227 | 221 | ||
228 | const userToCreate = new UserModel({ | 222 | const userToCreate = buildUser({ |
229 | username: body.username, | 223 | ...pick(body, [ 'username', 'password', 'email' ]), |
230 | password: body.password, | 224 | |
231 | email: body.email, | ||
232 | nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, | ||
233 | p2pEnabled: CONFIG.DEFAULTS.P2P.WEBAPP.ENABLED, | ||
234 | autoPlayVideo: true, | ||
235 | role: UserRole.USER, | ||
236 | videoQuota: CONFIG.USER.VIDEO_QUOTA, | ||
237 | videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY, | ||
238 | emailVerified: CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION ? false : null | 225 | emailVerified: CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION ? false : null |
239 | }) | 226 | }) |
240 | 227 | ||
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index c2ad0b710..595abcf95 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts | |||
@@ -1,7 +1,9 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import express from 'express' | 2 | import express from 'express' |
3 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' | 3 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' |
4 | import { getBiggestActorImage } from '@server/lib/actor-image' | ||
4 | import { Hooks } from '@server/lib/plugins/hooks' | 5 | import { Hooks } from '@server/lib/plugins/hooks' |
6 | import { pick } from '@shared/core-utils' | ||
5 | import { ActorImageType, HttpStatusCode, UserUpdateMe, UserVideoQuota, UserVideoRate as FormattedUserVideoRate } from '@shared/models' | 7 | import { ActorImageType, HttpStatusCode, UserUpdateMe, UserVideoQuota, UserVideoRate as FormattedUserVideoRate } from '@shared/models' |
6 | import { AttributesOnly } from '@shared/typescript-utils' | 8 | import { AttributesOnly } from '@shared/typescript-utils' |
7 | import { createReqFiles } from '../../../helpers/express-utils' | 9 | import { createReqFiles } from '../../../helpers/express-utils' |
@@ -10,7 +12,7 @@ import { CONFIG } from '../../../initializers/config' | |||
10 | import { MIMETYPES } from '../../../initializers/constants' | 12 | import { MIMETYPES } from '../../../initializers/constants' |
11 | import { sequelizeTypescript } from '../../../initializers/database' | 13 | import { sequelizeTypescript } from '../../../initializers/database' |
12 | import { sendUpdateActor } from '../../../lib/activitypub/send' | 14 | import { sendUpdateActor } from '../../../lib/activitypub/send' |
13 | import { deleteLocalActorImageFile, updateLocalActorImageFile } from '../../../lib/local-actor' | 15 | import { deleteLocalActorImageFile, updateLocalActorImageFiles } from '../../../lib/local-actor' |
14 | import { getOriginalVideoFileTotalDailyFromUser, getOriginalVideoFileTotalFromUser, sendVerifyUserEmail } from '../../../lib/user' | 16 | import { getOriginalVideoFileTotalDailyFromUser, getOriginalVideoFileTotalFromUser, sendVerifyUserEmail } from '../../../lib/user' |
15 | import { | 17 | import { |
16 | asyncMiddleware, | 18 | asyncMiddleware, |
@@ -30,11 +32,10 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat | |||
30 | import { UserModel } from '../../../models/user/user' | 32 | import { UserModel } from '../../../models/user/user' |
31 | import { VideoModel } from '../../../models/video/video' | 33 | import { VideoModel } from '../../../models/video/video' |
32 | import { VideoImportModel } from '../../../models/video/video-import' | 34 | import { VideoImportModel } from '../../../models/video/video-import' |
33 | import { pick } from '@shared/core-utils' | ||
34 | 35 | ||
35 | const auditLogger = auditLoggerFactory('users') | 36 | const auditLogger = auditLoggerFactory('users') |
36 | 37 | ||
37 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) | 38 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT) |
38 | 39 | ||
39 | const meRouter = express.Router() | 40 | const meRouter = express.Router() |
40 | 41 | ||
@@ -253,9 +254,17 @@ async function updateMyAvatar (req: express.Request, res: express.Response) { | |||
253 | 254 | ||
254 | const userAccount = await AccountModel.load(user.Account.id) | 255 | const userAccount = await AccountModel.load(user.Account.id) |
255 | 256 | ||
256 | const avatar = await updateLocalActorImageFile(userAccount, avatarPhysicalFile, ActorImageType.AVATAR) | 257 | const avatars = await updateLocalActorImageFiles( |
258 | userAccount, | ||
259 | avatarPhysicalFile, | ||
260 | ActorImageType.AVATAR | ||
261 | ) | ||
257 | 262 | ||
258 | return res.json({ avatar: avatar.toFormattedJSON() }) | 263 | return res.json({ |
264 | // TODO: remove, deprecated in 4.2 | ||
265 | avatar: getBiggestActorImage(avatars).toFormattedJSON(), | ||
266 | avatars: avatars.map(avatar => avatar.toFormattedJSON()) | ||
267 | }) | ||
259 | } | 268 | } |
260 | 269 | ||
261 | async function deleteMyAvatar (req: express.Request, res: express.Response) { | 270 | async function deleteMyAvatar (req: express.Request, res: express.Response) { |
@@ -264,5 +273,5 @@ async function deleteMyAvatar (req: express.Request, res: express.Response) { | |||
264 | const userAccount = await AccountModel.load(user.Account.id) | 273 | const userAccount = await AccountModel.load(user.Account.id) |
265 | await deleteLocalActorImageFile(userAccount, ActorImageType.AVATAR) | 274 | await deleteLocalActorImageFile(userAccount, ActorImageType.AVATAR) |
266 | 275 | ||
267 | return res.status(HttpStatusCode.NO_CONTENT_204).end() | 276 | return res.json({ avatars: [] }) |
268 | } | 277 | } |
diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts index d107a306e..58732158f 100644 --- a/server/controllers/api/users/my-notifications.ts +++ b/server/controllers/api/users/my-notifications.ts | |||
@@ -3,7 +3,6 @@ import express from 'express' | |||
3 | import { UserNotificationModel } from '@server/models/user/user-notification' | 3 | import { UserNotificationModel } from '@server/models/user/user-notification' |
4 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 4 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
5 | import { UserNotificationSetting } from '../../../../shared/models/users' | 5 | import { UserNotificationSetting } from '../../../../shared/models/users' |
6 | import { getFormattedObjects } from '../../../helpers/utils' | ||
7 | import { | 6 | import { |
8 | asyncMiddleware, | 7 | asyncMiddleware, |
9 | asyncRetryTransactionMiddleware, | 8 | asyncRetryTransactionMiddleware, |
@@ -20,6 +19,7 @@ import { | |||
20 | } from '../../../middlewares/validators/user-notifications' | 19 | } from '../../../middlewares/validators/user-notifications' |
21 | import { UserNotificationSettingModel } from '../../../models/user/user-notification-setting' | 20 | import { UserNotificationSettingModel } from '../../../models/user/user-notification-setting' |
22 | import { meRouter } from './me' | 21 | import { meRouter } from './me' |
22 | import { getFormattedObjects } from '@server/helpers/utils' | ||
23 | 23 | ||
24 | const myNotificationsRouter = express.Router() | 24 | const myNotificationsRouter = express.Router() |
25 | 25 | ||
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index e65550a22..2454b1ec9 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { pickCommonVideoQuery } from '@server/helpers/query' | 2 | import { pickCommonVideoQuery } from '@server/helpers/query' |
3 | import { getBiggestActorImage } from '@server/lib/actor-image' | ||
3 | import { Hooks } from '@server/lib/plugins/hooks' | 4 | import { Hooks } from '@server/lib/plugins/hooks' |
4 | import { ActorFollowModel } from '@server/models/actor/actor-follow' | 5 | import { ActorFollowModel } from '@server/models/actor/actor-follow' |
5 | import { getServerActor } from '@server/models/application/application' | 6 | import { getServerActor } from '@server/models/application/application' |
@@ -11,12 +12,11 @@ import { resetSequelizeInstance } from '../../helpers/database-utils' | |||
11 | import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | 12 | import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' |
12 | import { logger } from '../../helpers/logger' | 13 | import { logger } from '../../helpers/logger' |
13 | import { getFormattedObjects } from '../../helpers/utils' | 14 | import { getFormattedObjects } from '../../helpers/utils' |
14 | import { CONFIG } from '../../initializers/config' | ||
15 | import { MIMETYPES } from '../../initializers/constants' | 15 | import { MIMETYPES } from '../../initializers/constants' |
16 | import { sequelizeTypescript } from '../../initializers/database' | 16 | import { sequelizeTypescript } from '../../initializers/database' |
17 | import { sendUpdateActor } from '../../lib/activitypub/send' | 17 | import { sendUpdateActor } from '../../lib/activitypub/send' |
18 | import { JobQueue } from '../../lib/job-queue' | 18 | import { JobQueue } from '../../lib/job-queue' |
19 | import { deleteLocalActorImageFile, updateLocalActorImageFile } from '../../lib/local-actor' | 19 | import { deleteLocalActorImageFile, updateLocalActorImageFiles } from '../../lib/local-actor' |
20 | import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' | 20 | import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' |
21 | import { | 21 | import { |
22 | asyncMiddleware, | 22 | asyncMiddleware, |
@@ -50,8 +50,8 @@ import { VideoChannelModel } from '../../models/video/video-channel' | |||
50 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 50 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
51 | 51 | ||
52 | const auditLogger = auditLoggerFactory('channels') | 52 | const auditLogger = auditLoggerFactory('channels') |
53 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) | 53 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT) |
54 | const reqBannerFile = createReqFiles([ 'bannerfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { bannerfile: CONFIG.STORAGE.TMP_DIR }) | 54 | const reqBannerFile = createReqFiles([ 'bannerfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT) |
55 | 55 | ||
56 | const videoChannelRouter = express.Router() | 56 | const videoChannelRouter = express.Router() |
57 | 57 | ||
@@ -186,11 +186,15 @@ async function updateVideoChannelBanner (req: express.Request, res: express.Resp | |||
186 | const videoChannel = res.locals.videoChannel | 186 | const videoChannel = res.locals.videoChannel |
187 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) | 187 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) |
188 | 188 | ||
189 | const banner = await updateLocalActorImageFile(videoChannel, bannerPhysicalFile, ActorImageType.BANNER) | 189 | const banners = await updateLocalActorImageFiles(videoChannel, bannerPhysicalFile, ActorImageType.BANNER) |
190 | 190 | ||
191 | auditLogger.update(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys) | 191 | auditLogger.update(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys) |
192 | 192 | ||
193 | return res.json({ banner: banner.toFormattedJSON() }) | 193 | return res.json({ |
194 | // TODO: remove, deprecated in 4.2 | ||
195 | banner: getBiggestActorImage(banners).toFormattedJSON(), | ||
196 | banners: banners.map(b => b.toFormattedJSON()) | ||
197 | }) | ||
194 | } | 198 | } |
195 | 199 | ||
196 | async function updateVideoChannelAvatar (req: express.Request, res: express.Response) { | 200 | async function updateVideoChannelAvatar (req: express.Request, res: express.Response) { |
@@ -198,11 +202,14 @@ async function updateVideoChannelAvatar (req: express.Request, res: express.Resp | |||
198 | const videoChannel = res.locals.videoChannel | 202 | const videoChannel = res.locals.videoChannel |
199 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) | 203 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) |
200 | 204 | ||
201 | const avatar = await updateLocalActorImageFile(videoChannel, avatarPhysicalFile, ActorImageType.AVATAR) | 205 | const avatars = await updateLocalActorImageFiles(videoChannel, avatarPhysicalFile, ActorImageType.AVATAR) |
202 | |||
203 | auditLogger.update(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys) | 206 | auditLogger.update(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys) |
204 | 207 | ||
205 | return res.json({ avatar: avatar.toFormattedJSON() }) | 208 | return res.json({ |
209 | // TODO: remove, deprecated in 4.2 | ||
210 | avatar: getBiggestActorImage(avatars).toFormattedJSON(), | ||
211 | avatars: avatars.map(a => a.toFormattedJSON()) | ||
212 | }) | ||
206 | } | 213 | } |
207 | 214 | ||
208 | async function deleteVideoChannelAvatar (req: express.Request, res: express.Response) { | 215 | async function deleteVideoChannelAvatar (req: express.Request, res: express.Response) { |
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index 795e14e73..1255d14c6 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts | |||
@@ -47,7 +47,7 @@ import { AccountModel } from '../../models/account/account' | |||
47 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 47 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
48 | import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' | 48 | import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' |
49 | 49 | ||
50 | const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) | 50 | const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT) |
51 | 51 | ||
52 | const videoPlaylistRouter = express.Router() | 52 | const videoPlaylistRouter = express.Router() |
53 | 53 | ||
@@ -453,13 +453,19 @@ async function getVideoPlaylistVideos (req: express.Request, res: express.Respon | |||
453 | const user = res.locals.oauth ? res.locals.oauth.token.User : undefined | 453 | const user = res.locals.oauth ? res.locals.oauth.token.User : undefined |
454 | const server = await getServerActor() | 454 | const server = await getServerActor() |
455 | 455 | ||
456 | const resultList = await VideoPlaylistElementModel.listForApi({ | 456 | const apiOptions = await Hooks.wrapObject({ |
457 | start: req.query.start, | 457 | start: req.query.start, |
458 | count: req.query.count, | 458 | count: req.query.count, |
459 | videoPlaylistId: videoPlaylistInstance.id, | 459 | videoPlaylistId: videoPlaylistInstance.id, |
460 | serverAccount: server.Account, | 460 | serverAccount: server.Account, |
461 | user | 461 | user |
462 | }) | 462 | }, 'filter:api.video-playlist.videos.list.params') |
463 | |||
464 | const resultList = await Hooks.wrapPromiseFun( | ||
465 | VideoPlaylistElementModel.listForApi, | ||
466 | apiOptions, | ||
467 | 'filter:api.video-playlist.videos.list.result' | ||
468 | ) | ||
463 | 469 | ||
464 | const options = { | 470 | const options = { |
465 | displayNSFW: buildNSFWFilter(res, req.query.nsfw), | 471 | displayNSFW: buildNSFWFilter(res, req.query.nsfw), |
diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts index 2a9a9d233..2b511a398 100644 --- a/server/controllers/api/videos/captions.ts +++ b/server/controllers/api/videos/captions.ts | |||
@@ -1,26 +1,19 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { Hooks } from '@server/lib/plugins/hooks' | ||
2 | import { MVideoCaption } from '@server/types/models' | 3 | import { MVideoCaption } from '@server/types/models' |
3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 4 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' | 5 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' |
5 | import { createReqFiles } from '../../../helpers/express-utils' | 6 | import { createReqFiles } from '../../../helpers/express-utils' |
6 | import { logger } from '../../../helpers/logger' | 7 | import { logger } from '../../../helpers/logger' |
7 | import { getFormattedObjects } from '../../../helpers/utils' | 8 | import { getFormattedObjects } from '../../../helpers/utils' |
8 | import { CONFIG } from '../../../initializers/config' | ||
9 | import { MIMETYPES } from '../../../initializers/constants' | 9 | import { MIMETYPES } from '../../../initializers/constants' |
10 | import { sequelizeTypescript } from '../../../initializers/database' | 10 | import { sequelizeTypescript } from '../../../initializers/database' |
11 | import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' | 11 | import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' |
12 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' | 12 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' |
13 | import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators' | 13 | import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators' |
14 | import { VideoCaptionModel } from '../../../models/video/video-caption' | 14 | import { VideoCaptionModel } from '../../../models/video/video-caption' |
15 | import { Hooks } from '@server/lib/plugins/hooks' | ||
16 | 15 | ||
17 | const reqVideoCaptionAdd = createReqFiles( | 16 | const reqVideoCaptionAdd = createReqFiles([ 'captionfile' ], MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT) |
18 | [ 'captionfile' ], | ||
19 | MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT, | ||
20 | { | ||
21 | captionfile: CONFIG.STORAGE.CAPTIONS_DIR | ||
22 | } | ||
23 | ) | ||
24 | 17 | ||
25 | const videoCaptionsRouter = express.Router() | 18 | const videoCaptionsRouter = express.Router() |
26 | 19 | ||
diff --git a/server/controllers/api/videos/editor.ts b/server/controllers/api/videos/editor.ts new file mode 100644 index 000000000..588cc1a8c --- /dev/null +++ b/server/controllers/api/videos/editor.ts | |||
@@ -0,0 +1,118 @@ | |||
1 | import express from 'express' | ||
2 | import { createAnyReqFiles } from '@server/helpers/express-utils' | ||
3 | import { MIMETYPES } from '@server/initializers/constants' | ||
4 | import { JobQueue } from '@server/lib/job-queue' | ||
5 | import { buildTaskFileFieldname, getTaskFile } from '@server/lib/video-editor' | ||
6 | import { | ||
7 | HttpStatusCode, | ||
8 | VideoEditionTaskPayload, | ||
9 | VideoEditorCreateEdition, | ||
10 | VideoEditorTask, | ||
11 | VideoEditorTaskCut, | ||
12 | VideoEditorTaskIntro, | ||
13 | VideoEditorTaskOutro, | ||
14 | VideoEditorTaskWatermark, | ||
15 | VideoState | ||
16 | } from '@shared/models' | ||
17 | import { asyncMiddleware, authenticate, videosEditorAddEditionValidator } from '../../../middlewares' | ||
18 | |||
19 | const editorRouter = express.Router() | ||
20 | |||
21 | const tasksFiles = createAnyReqFiles( | ||
22 | MIMETYPES.VIDEO.MIMETYPE_EXT, | ||
23 | (req: express.Request, file: Express.Multer.File, cb: (err: Error, result?: boolean) => void) => { | ||
24 | const body = req.body as VideoEditorCreateEdition | ||
25 | |||
26 | // Fetch array element | ||
27 | const matches = file.fieldname.match(/tasks\[(\d+)\]/) | ||
28 | if (!matches) return cb(new Error('Cannot find array element indice for ' + file.fieldname)) | ||
29 | |||
30 | const indice = parseInt(matches[1]) | ||
31 | const task = body.tasks[indice] | ||
32 | |||
33 | if (!task) return cb(new Error('Cannot find array element of indice ' + indice + ' for ' + file.fieldname)) | ||
34 | |||
35 | if ( | ||
36 | [ 'add-intro', 'add-outro', 'add-watermark' ].includes(task.name) && | ||
37 | file.fieldname === buildTaskFileFieldname(indice) | ||
38 | ) { | ||
39 | return cb(null, true) | ||
40 | } | ||
41 | |||
42 | return cb(null, false) | ||
43 | } | ||
44 | ) | ||
45 | |||
46 | editorRouter.post('/:videoId/editor/edit', | ||
47 | authenticate, | ||
48 | tasksFiles, | ||
49 | asyncMiddleware(videosEditorAddEditionValidator), | ||
50 | asyncMiddleware(createEditionTasks) | ||
51 | ) | ||
52 | |||
53 | // --------------------------------------------------------------------------- | ||
54 | |||
55 | export { | ||
56 | editorRouter | ||
57 | } | ||
58 | |||
59 | // --------------------------------------------------------------------------- | ||
60 | |||
61 | async function createEditionTasks (req: express.Request, res: express.Response) { | ||
62 | const files = req.files as Express.Multer.File[] | ||
63 | const body = req.body as VideoEditorCreateEdition | ||
64 | const video = res.locals.videoAll | ||
65 | |||
66 | video.state = VideoState.TO_EDIT | ||
67 | await video.save() | ||
68 | |||
69 | const payload = { | ||
70 | videoUUID: video.uuid, | ||
71 | tasks: body.tasks.map((t, i) => buildTaskPayload(t, i, files)) | ||
72 | } | ||
73 | |||
74 | JobQueue.Instance.createJob({ type: 'video-edition', payload }) | ||
75 | |||
76 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | ||
77 | } | ||
78 | |||
79 | const taskPayloadBuilders: { | ||
80 | [id in VideoEditorTask['name']]: (task: VideoEditorTask, indice?: number, files?: Express.Multer.File[]) => VideoEditionTaskPayload | ||
81 | } = { | ||
82 | 'add-intro': buildIntroOutroTask, | ||
83 | 'add-outro': buildIntroOutroTask, | ||
84 | 'cut': buildCutTask, | ||
85 | 'add-watermark': buildWatermarkTask | ||
86 | } | ||
87 | |||
88 | function buildTaskPayload (task: VideoEditorTask, indice: number, files: Express.Multer.File[]): VideoEditionTaskPayload { | ||
89 | return taskPayloadBuilders[task.name](task, indice, files) | ||
90 | } | ||
91 | |||
92 | function buildIntroOutroTask (task: VideoEditorTaskIntro | VideoEditorTaskOutro, indice: number, files: Express.Multer.File[]) { | ||
93 | return { | ||
94 | name: task.name, | ||
95 | options: { | ||
96 | file: getTaskFile(files, indice).path | ||
97 | } | ||
98 | } | ||
99 | } | ||
100 | |||
101 | function buildCutTask (task: VideoEditorTaskCut) { | ||
102 | return { | ||
103 | name: task.name, | ||
104 | options: { | ||
105 | start: task.options.start, | ||
106 | end: task.options.end | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | |||
111 | function buildWatermarkTask (task: VideoEditorTaskWatermark, indice: number, files: Express.Multer.File[]) { | ||
112 | return { | ||
113 | name: task.name, | ||
114 | options: { | ||
115 | file: getTaskFile(files, indice).path | ||
116 | } | ||
117 | } | ||
118 | } | ||
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index b54fa822c..44283e266 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -61,12 +61,7 @@ const videoImportsRouter = express.Router() | |||
61 | 61 | ||
62 | const reqVideoFileImport = createReqFiles( | 62 | const reqVideoFileImport = createReqFiles( |
63 | [ 'thumbnailfile', 'previewfile', 'torrentfile' ], | 63 | [ 'thumbnailfile', 'previewfile', 'torrentfile' ], |
64 | Object.assign({}, MIMETYPES.TORRENT.MIMETYPE_EXT, MIMETYPES.IMAGE.MIMETYPE_EXT), | 64 | { ...MIMETYPES.TORRENT.MIMETYPE_EXT, ...MIMETYPES.IMAGE.MIMETYPE_EXT } |
65 | { | ||
66 | thumbnailfile: CONFIG.STORAGE.TMP_DIR, | ||
67 | previewfile: CONFIG.STORAGE.TMP_DIR, | ||
68 | torrentfile: CONFIG.STORAGE.TMP_DIR | ||
69 | } | ||
70 | ) | 65 | ) |
71 | 66 | ||
72 | videoImportsRouter.post('/imports', | 67 | videoImportsRouter.post('/imports', |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 61a030ba1..a5ae07d95 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -35,6 +35,7 @@ import { VideoModel } from '../../../models/video/video' | |||
35 | import { blacklistRouter } from './blacklist' | 35 | import { blacklistRouter } from './blacklist' |
36 | import { videoCaptionsRouter } from './captions' | 36 | import { videoCaptionsRouter } from './captions' |
37 | import { videoCommentRouter } from './comment' | 37 | import { videoCommentRouter } from './comment' |
38 | import { editorRouter } from './editor' | ||
38 | import { filesRouter } from './files' | 39 | import { filesRouter } from './files' |
39 | import { videoImportsRouter } from './import' | 40 | import { videoImportsRouter } from './import' |
40 | import { liveRouter } from './live' | 41 | import { liveRouter } from './live' |
@@ -51,6 +52,7 @@ const videosRouter = express.Router() | |||
51 | videosRouter.use('/', blacklistRouter) | 52 | videosRouter.use('/', blacklistRouter) |
52 | videosRouter.use('/', rateVideoRouter) | 53 | videosRouter.use('/', rateVideoRouter) |
53 | videosRouter.use('/', videoCommentRouter) | 54 | videosRouter.use('/', videoCommentRouter) |
55 | videosRouter.use('/', editorRouter) | ||
54 | videosRouter.use('/', videoCaptionsRouter) | 56 | videosRouter.use('/', videoCaptionsRouter) |
55 | videosRouter.use('/', videoImportsRouter) | 57 | videosRouter.use('/', videoImportsRouter) |
56 | videosRouter.use('/', ownershipVideoRouter) | 58 | videosRouter.use('/', ownershipVideoRouter) |
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts index 8b8cacff9..49cabb6f3 100644 --- a/server/controllers/api/videos/live.ts +++ b/server/controllers/api/videos/live.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { createReqFiles } from '@server/helpers/express-utils' | 2 | import { createReqFiles } from '@server/helpers/express-utils' |
3 | import { CONFIG } from '@server/initializers/config' | ||
4 | import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants' | 3 | import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants' |
5 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' | 4 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' |
6 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' | 5 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' |
@@ -19,14 +18,7 @@ import { VideoModel } from '../../../models/video/video' | |||
19 | 18 | ||
20 | const liveRouter = express.Router() | 19 | const liveRouter = express.Router() |
21 | 20 | ||
22 | const reqVideoFileLive = createReqFiles( | 21 | const reqVideoFileLive = createReqFiles([ 'thumbnailfile', 'previewfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT) |
23 | [ 'thumbnailfile', 'previewfile' ], | ||
24 | MIMETYPES.IMAGE.MIMETYPE_EXT, | ||
25 | { | ||
26 | thumbnailfile: CONFIG.STORAGE.TMP_DIR, | ||
27 | previewfile: CONFIG.STORAGE.TMP_DIR | ||
28 | } | ||
29 | ) | ||
30 | 22 | ||
31 | liveRouter.post('/live', | 23 | liveRouter.post('/live', |
32 | authenticate, | 24 | authenticate, |
diff --git a/server/controllers/api/videos/transcoding.ts b/server/controllers/api/videos/transcoding.ts index fba4545c2..da3ea3c9c 100644 --- a/server/controllers/api/videos/transcoding.ts +++ b/server/controllers/api/videos/transcoding.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { computeLowerResolutionsToTranscode } from '@server/helpers/ffprobe-utils' | 2 | import { computeLowerResolutionsToTranscode } from '@server/helpers/ffmpeg' |
3 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | 3 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
4 | import { addTranscodingJob } from '@server/lib/video' | 4 | import { addTranscodingJob } from '@server/lib/video' |
5 | import { HttpStatusCode, UserRight, VideoState, VideoTranscodingCreate } from '@shared/models' | 5 | import { HttpStatusCode, UserRight, VideoState, VideoTranscodingCreate } from '@shared/models' |
@@ -29,7 +29,7 @@ async function createTranscoding (req: express.Request, res: express.Response) { | |||
29 | 29 | ||
30 | const body: VideoTranscodingCreate = req.body | 30 | const body: VideoTranscodingCreate = req.body |
31 | 31 | ||
32 | const { resolution: maxResolution, isPortraitMode, audioStream } = await video.getMaxQualityFileInfo() | 32 | const { resolution: maxResolution, isPortraitMode, audioStream } = await video.probeMaxQualityFile() |
33 | const resolutions = computeLowerResolutionsToTranscode(maxResolution, 'vod').concat([ maxResolution ]) | 33 | const resolutions = computeLowerResolutionsToTranscode(maxResolution, 'vod').concat([ maxResolution ]) |
34 | 34 | ||
35 | video.state = VideoState.TO_TRANSCODE | 35 | video.state = VideoState.TO_TRANSCODE |
diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts index c01d9276a..15899307d 100644 --- a/server/controllers/api/videos/update.ts +++ b/server/controllers/api/videos/update.ts | |||
@@ -11,7 +11,6 @@ import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../ | |||
11 | import { resetSequelizeInstance } from '../../../helpers/database-utils' | 11 | import { resetSequelizeInstance } from '../../../helpers/database-utils' |
12 | import { createReqFiles } from '../../../helpers/express-utils' | 12 | import { createReqFiles } from '../../../helpers/express-utils' |
13 | import { logger, loggerTagsFactory } from '../../../helpers/logger' | 13 | import { logger, loggerTagsFactory } from '../../../helpers/logger' |
14 | import { CONFIG } from '../../../initializers/config' | ||
15 | import { MIMETYPES } from '../../../initializers/constants' | 14 | import { MIMETYPES } from '../../../initializers/constants' |
16 | import { sequelizeTypescript } from '../../../initializers/database' | 15 | import { sequelizeTypescript } from '../../../initializers/database' |
17 | import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' | 16 | import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' |
@@ -26,14 +25,7 @@ const lTags = loggerTagsFactory('api', 'video') | |||
26 | const auditLogger = auditLoggerFactory('videos') | 25 | const auditLogger = auditLoggerFactory('videos') |
27 | const updateRouter = express.Router() | 26 | const updateRouter = express.Router() |
28 | 27 | ||
29 | const reqVideoFileUpdate = createReqFiles( | 28 | const reqVideoFileUpdate = createReqFiles([ 'thumbnailfile', 'previewfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT) |
30 | [ 'thumbnailfile', 'previewfile' ], | ||
31 | MIMETYPES.IMAGE.MIMETYPE_EXT, | ||
32 | { | ||
33 | thumbnailfile: CONFIG.STORAGE.TMP_DIR, | ||
34 | previewfile: CONFIG.STORAGE.TMP_DIR | ||
35 | } | ||
36 | ) | ||
37 | 29 | ||
38 | updateRouter.put('/:id', | 30 | updateRouter.put('/:id', |
39 | openapiOperationDoc({ operationId: 'putVideo' }), | 31 | openapiOperationDoc({ operationId: 'putVideo' }), |
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts index fd90d9915..dd69cf238 100644 --- a/server/controllers/api/videos/upload.ts +++ b/server/controllers/api/videos/upload.ts | |||
@@ -24,9 +24,8 @@ import { HttpStatusCode, VideoCreate, VideoResolution, VideoState } from '@share | |||
24 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 24 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
25 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 25 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
26 | import { createReqFiles } from '../../../helpers/express-utils' | 26 | import { createReqFiles } from '../../../helpers/express-utils' |
27 | import { ffprobePromise, getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' | 27 | import { buildFileMetadata, ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS } from '../../../helpers/ffmpeg' |
28 | import { logger, loggerTagsFactory } from '../../../helpers/logger' | 28 | import { logger, loggerTagsFactory } from '../../../helpers/logger' |
29 | import { CONFIG } from '../../../initializers/config' | ||
30 | import { MIMETYPES } from '../../../initializers/constants' | 29 | import { MIMETYPES } from '../../../initializers/constants' |
31 | import { sequelizeTypescript } from '../../../initializers/database' | 30 | import { sequelizeTypescript } from '../../../initializers/database' |
32 | import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' | 31 | import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' |
@@ -52,21 +51,13 @@ const uploadRouter = express.Router() | |||
52 | 51 | ||
53 | const reqVideoFileAdd = createReqFiles( | 52 | const reqVideoFileAdd = createReqFiles( |
54 | [ 'videofile', 'thumbnailfile', 'previewfile' ], | 53 | [ 'videofile', 'thumbnailfile', 'previewfile' ], |
55 | Object.assign({}, MIMETYPES.VIDEO.MIMETYPE_EXT, MIMETYPES.IMAGE.MIMETYPE_EXT), | 54 | { ...MIMETYPES.VIDEO.MIMETYPE_EXT, ...MIMETYPES.IMAGE.MIMETYPE_EXT } |
56 | { | ||
57 | videofile: CONFIG.STORAGE.TMP_DIR, | ||
58 | thumbnailfile: CONFIG.STORAGE.TMP_DIR, | ||
59 | previewfile: CONFIG.STORAGE.TMP_DIR | ||
60 | } | ||
61 | ) | 55 | ) |
62 | 56 | ||
63 | const reqVideoFileAddResumable = createReqFiles( | 57 | const reqVideoFileAddResumable = createReqFiles( |
64 | [ 'thumbnailfile', 'previewfile' ], | 58 | [ 'thumbnailfile', 'previewfile' ], |
65 | MIMETYPES.IMAGE.MIMETYPE_EXT, | 59 | MIMETYPES.IMAGE.MIMETYPE_EXT, |
66 | { | 60 | getResumableUploadPath() |
67 | thumbnailfile: getResumableUploadPath(), | ||
68 | previewfile: getResumableUploadPath() | ||
69 | } | ||
70 | ) | 61 | ) |
71 | 62 | ||
72 | uploadRouter.post('/upload', | 63 | uploadRouter.post('/upload', |
@@ -246,7 +237,7 @@ async function buildNewFile (videoPhysicalFile: express.VideoUploadFile) { | |||
246 | extname: getLowercaseExtension(videoPhysicalFile.filename), | 237 | extname: getLowercaseExtension(videoPhysicalFile.filename), |
247 | size: videoPhysicalFile.size, | 238 | size: videoPhysicalFile.size, |
248 | videoStreamingPlaylistId: null, | 239 | videoStreamingPlaylistId: null, |
249 | metadata: await getMetadataFromFile(videoPhysicalFile.path) | 240 | metadata: await buildFileMetadata(videoPhysicalFile.path) |
250 | }) | 241 | }) |
251 | 242 | ||
252 | const probe = await ffprobePromise(videoPhysicalFile.path) | 243 | const probe = await ffprobePromise(videoPhysicalFile.path) |
@@ -254,8 +245,8 @@ async function buildNewFile (videoPhysicalFile: express.VideoUploadFile) { | |||
254 | if (await isAudioFile(videoPhysicalFile.path, probe)) { | 245 | if (await isAudioFile(videoPhysicalFile.path, probe)) { |
255 | videoFile.resolution = VideoResolution.H_NOVIDEO | 246 | videoFile.resolution = VideoResolution.H_NOVIDEO |
256 | } else { | 247 | } else { |
257 | videoFile.fps = await getVideoFileFPS(videoPhysicalFile.path, probe) | 248 | videoFile.fps = await getVideoStreamFPS(videoPhysicalFile.path, probe) |
258 | videoFile.resolution = (await getVideoFileResolution(videoPhysicalFile.path, probe)).resolution | 249 | videoFile.resolution = (await getVideoStreamDimensionsInfo(videoPhysicalFile.path, probe)).resolution |
259 | } | 250 | } |
260 | 251 | ||
261 | videoFile.filename = generateWebTorrentVideoFilename(videoFile.resolution, videoFile.extname) | 252 | videoFile.filename = generateWebTorrentVideoFilename(videoFile.resolution, videoFile.extname) |
diff --git a/server/controllers/client.ts b/server/controllers/client.ts index 8a56f2f75..f9514d988 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts | |||
@@ -68,7 +68,9 @@ const staticClientOverrides = [ | |||
68 | 'assets/images/icons/icon-512x512.png', | 68 | 'assets/images/icons/icon-512x512.png', |
69 | 'assets/images/default-playlist.jpg', | 69 | 'assets/images/default-playlist.jpg', |
70 | 'assets/images/default-avatar-account.png', | 70 | 'assets/images/default-avatar-account.png', |
71 | 'assets/images/default-avatar-video-channel.png' | 71 | 'assets/images/default-avatar-account-48x48.png', |
72 | 'assets/images/default-avatar-video-channel.png', | ||
73 | 'assets/images/default-avatar-video-channel-48x48.png' | ||
72 | ] | 74 | ] |
73 | 75 | ||
74 | for (const staticClientOverride of staticClientOverrides) { | 76 | for (const staticClientOverride of staticClientOverrides) { |
diff --git a/server/controllers/lazy-static.ts b/server/controllers/lazy-static.ts index a4076ee56..55bf02660 100644 --- a/server/controllers/lazy-static.ts +++ b/server/controllers/lazy-static.ts | |||
@@ -64,7 +64,15 @@ async function getActorImage (req: express.Request, res: express.Response, next: | |||
64 | logger.info('Lazy serve remote actor image %s.', image.fileUrl) | 64 | logger.info('Lazy serve remote actor image %s.', image.fileUrl) |
65 | 65 | ||
66 | try { | 66 | try { |
67 | await pushActorImageProcessInQueue({ filename: image.filename, fileUrl: image.fileUrl, type: image.type }) | 67 | await pushActorImageProcessInQueue({ |
68 | filename: image.filename, | ||
69 | fileUrl: image.fileUrl, | ||
70 | size: { | ||
71 | height: image.height, | ||
72 | width: image.width | ||
73 | }, | ||
74 | type: image.type | ||
75 | }) | ||
68 | } catch (err) { | 76 | } catch (err) { |
69 | logger.warn('Cannot process remote actor image %s.', image.fileUrl, { err }) | 77 | logger.warn('Cannot process remote actor image %s.', image.fileUrl, { err }) |
70 | return res.status(HttpStatusCode.NOT_FOUND_404).end() | 78 | return res.status(HttpStatusCode.NOT_FOUND_404).end() |