diff options
-rw-r--r-- | server/controllers/api/users/me.ts | 6 | ||||
-rw-r--r-- | server/controllers/api/video-channel.ts | 6 | ||||
-rw-r--r-- | server/initializers/constants.ts | 4 | ||||
-rw-r--r-- | server/lib/avatar.ts | 9 |
4 files changed, 13 insertions, 12 deletions
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index c4e8d8130..5a3e9e51a 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts | |||
@@ -11,7 +11,7 @@ import { CONFIG } from '../../../initializers/config' | |||
11 | import { MIMETYPES } from '../../../initializers/constants' | 11 | import { MIMETYPES } from '../../../initializers/constants' |
12 | import { sequelizeTypescript } from '../../../initializers/database' | 12 | import { sequelizeTypescript } from '../../../initializers/database' |
13 | import { sendUpdateActor } from '../../../lib/activitypub/send' | 13 | import { sendUpdateActor } from '../../../lib/activitypub/send' |
14 | import { deleteActorAvatarFile, updateActorAvatarFile } from '../../../lib/avatar' | 14 | import { deleteLocalActorAvatarFile, updateLocalActorAvatarFile } from '../../../lib/avatar' |
15 | import { getOriginalVideoFileTotalDailyFromUser, getOriginalVideoFileTotalFromUser, sendVerifyUserEmail } from '../../../lib/user' | 15 | import { getOriginalVideoFileTotalDailyFromUser, getOriginalVideoFileTotalFromUser, sendVerifyUserEmail } from '../../../lib/user' |
16 | import { | 16 | import { |
17 | asyncMiddleware, | 17 | asyncMiddleware, |
@@ -238,7 +238,7 @@ async function updateMyAvatar (req: express.Request, res: express.Response) { | |||
238 | 238 | ||
239 | const userAccount = await AccountModel.load(user.Account.id) | 239 | const userAccount = await AccountModel.load(user.Account.id) |
240 | 240 | ||
241 | const avatar = await updateActorAvatarFile(userAccount, avatarPhysicalFile) | 241 | const avatar = await updateLocalActorAvatarFile(userAccount, avatarPhysicalFile) |
242 | 242 | ||
243 | return res.json({ avatar: avatar.toFormattedJSON() }) | 243 | return res.json({ avatar: avatar.toFormattedJSON() }) |
244 | } | 244 | } |
@@ -247,7 +247,7 @@ async function deleteMyAvatar (req: express.Request, res: express.Response) { | |||
247 | const user = res.locals.oauth.token.user | 247 | const user = res.locals.oauth.token.user |
248 | 248 | ||
249 | const userAccount = await AccountModel.load(user.Account.id) | 249 | const userAccount = await AccountModel.load(user.Account.id) |
250 | await deleteActorAvatarFile(userAccount) | 250 | await deleteLocalActorAvatarFile(userAccount) |
251 | 251 | ||
252 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | 252 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) |
253 | } | 253 | } |
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index 7ac01b0ef..14bd64730 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts | |||
@@ -13,7 +13,7 @@ import { MIMETYPES } from '../../initializers/constants' | |||
13 | import { sequelizeTypescript } from '../../initializers/database' | 13 | import { sequelizeTypescript } from '../../initializers/database' |
14 | import { setAsyncActorKeys } from '../../lib/activitypub/actor' | 14 | import { setAsyncActorKeys } from '../../lib/activitypub/actor' |
15 | import { sendUpdateActor } from '../../lib/activitypub/send' | 15 | import { sendUpdateActor } from '../../lib/activitypub/send' |
16 | import { deleteActorAvatarFile, updateActorAvatarFile } from '../../lib/avatar' | 16 | import { deleteLocalActorAvatarFile, updateLocalActorAvatarFile } from '../../lib/avatar' |
17 | import { JobQueue } from '../../lib/job-queue' | 17 | import { JobQueue } from '../../lib/job-queue' |
18 | import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' | 18 | import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' |
19 | import { | 19 | import { |
@@ -140,7 +140,7 @@ async function updateVideoChannelAvatar (req: express.Request, res: express.Resp | |||
140 | const videoChannel = res.locals.videoChannel | 140 | const videoChannel = res.locals.videoChannel |
141 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) | 141 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) |
142 | 142 | ||
143 | const avatar = await updateActorAvatarFile(videoChannel, avatarPhysicalFile) | 143 | const avatar = await updateLocalActorAvatarFile(videoChannel, avatarPhysicalFile) |
144 | 144 | ||
145 | auditLogger.update(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys) | 145 | auditLogger.update(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys) |
146 | 146 | ||
@@ -154,7 +154,7 @@ async function updateVideoChannelAvatar (req: express.Request, res: express.Resp | |||
154 | async function deleteVideoChannelAvatar (req: express.Request, res: express.Response) { | 154 | async function deleteVideoChannelAvatar (req: express.Request, res: express.Response) { |
155 | const videoChannel = res.locals.videoChannel | 155 | const videoChannel = res.locals.videoChannel |
156 | 156 | ||
157 | await deleteActorAvatarFile(videoChannel) | 157 | await deleteLocalActorAvatarFile(videoChannel) |
158 | 158 | ||
159 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | 159 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) |
160 | } | 160 | } |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 453ca02ed..c06eb6fb0 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -264,7 +264,7 @@ const CONSTRAINTS_FIELDS = { | |||
264 | DESCRIPTION: { min: 3, max: 10000 }, // Length | 264 | DESCRIPTION: { min: 3, max: 10000 }, // Length |
265 | SUPPORT: { min: 3, max: 1000 }, // Length | 265 | SUPPORT: { min: 3, max: 1000 }, // Length |
266 | IMAGE: { | 266 | IMAGE: { |
267 | EXTNAME: [ '.jpg', '.jpeg' ], | 267 | EXTNAME: [ '.png', '.jpg', '.jpeg', '.webp' ], |
268 | FILE_SIZE: { | 268 | FILE_SIZE: { |
269 | max: 2 * 1024 * 1024 // 2MB | 269 | max: 2 * 1024 * 1024 // 2MB |
270 | } | 270 | } |
@@ -298,7 +298,7 @@ const CONSTRAINTS_FIELDS = { | |||
298 | PRIVATE_KEY: { min: 10, max: 5000 }, // Length | 298 | PRIVATE_KEY: { min: 10, max: 5000 }, // Length |
299 | URL: { min: 3, max: 2000 }, // Length | 299 | URL: { min: 3, max: 2000 }, // Length |
300 | AVATAR: { | 300 | AVATAR: { |
301 | EXTNAME: [ '.png', '.jpeg', '.jpg', '.gif' ], | 301 | EXTNAME: [ '.png', '.jpeg', '.jpg', '.gif', '.webp' ], |
302 | FILE_SIZE: { | 302 | FILE_SIZE: { |
303 | max: 2 * 1024 * 1024 // 2MB | 303 | max: 2 * 1024 * 1024 // 2MB |
304 | } | 304 | } |
diff --git a/server/lib/avatar.ts b/server/lib/avatar.ts index 9d59a4966..e79cd1546 100644 --- a/server/lib/avatar.ts +++ b/server/lib/avatar.ts | |||
@@ -13,11 +13,12 @@ import { queue } from 'async' | |||
13 | import { downloadImage } from '../helpers/requests' | 13 | import { downloadImage } from '../helpers/requests' |
14 | import { MAccountDefault, MChannelDefault } from '../types/models' | 14 | import { MAccountDefault, MChannelDefault } from '../types/models' |
15 | 15 | ||
16 | async function updateActorAvatarFile ( | 16 | async function updateLocalActorAvatarFile ( |
17 | accountOrChannel: MAccountDefault | MChannelDefault, | 17 | accountOrChannel: MAccountDefault | MChannelDefault, |
18 | avatarPhysicalFile: Express.Multer.File | 18 | avatarPhysicalFile: Express.Multer.File |
19 | ) { | 19 | ) { |
20 | const extension = extname(avatarPhysicalFile.filename) | 20 | const extension = extname(avatarPhysicalFile.filename) |
21 | |||
21 | const avatarName = uuidv4() + extension | 22 | const avatarName = uuidv4() + extension |
22 | const destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName) | 23 | const destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName) |
23 | await processImage(avatarPhysicalFile.path, destination, AVATARS_SIZE) | 24 | await processImage(avatarPhysicalFile.path, destination, AVATARS_SIZE) |
@@ -40,7 +41,7 @@ async function updateActorAvatarFile ( | |||
40 | }) | 41 | }) |
41 | } | 42 | } |
42 | 43 | ||
43 | async function deleteActorAvatarFile ( | 44 | async function deleteLocalActorAvatarFile ( |
44 | accountOrChannel: MAccountDefault | MChannelDefault | 45 | accountOrChannel: MAccountDefault | MChannelDefault |
45 | ) { | 46 | ) { |
46 | return retryTransactionWrapper(() => { | 47 | return retryTransactionWrapper(() => { |
@@ -78,7 +79,7 @@ const avatarPathUnsafeCache = new LRUCache<string, string>({ max: LRU_CACHE.AVAT | |||
78 | 79 | ||
79 | export { | 80 | export { |
80 | avatarPathUnsafeCache, | 81 | avatarPathUnsafeCache, |
81 | updateActorAvatarFile, | 82 | updateLocalActorAvatarFile, |
82 | deleteActorAvatarFile, | 83 | deleteLocalActorAvatarFile, |
83 | pushAvatarProcessInQueue | 84 | pushAvatarProcessInQueue |
84 | } | 85 | } |