diff options
Diffstat (limited to 'server/controllers/api/users/me.ts')
-rw-r--r-- | server/controllers/api/users/me.ts | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index c2ad0b710..a1d621152 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,7 +32,6 @@ 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 | ||
@@ -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 | } |