aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users/me.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/users/me.ts')
-rw-r--r--server/controllers/api/users/me.ts19
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 @@
1import 'multer' 1import 'multer'
2import express from 'express' 2import express from 'express'
3import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' 3import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger'
4import { getBiggestActorImage } from '@server/lib/actor-image'
4import { Hooks } from '@server/lib/plugins/hooks' 5import { Hooks } from '@server/lib/plugins/hooks'
6import { pick } from '@shared/core-utils'
5import { ActorImageType, HttpStatusCode, UserUpdateMe, UserVideoQuota, UserVideoRate as FormattedUserVideoRate } from '@shared/models' 7import { ActorImageType, HttpStatusCode, UserUpdateMe, UserVideoQuota, UserVideoRate as FormattedUserVideoRate } from '@shared/models'
6import { AttributesOnly } from '@shared/typescript-utils' 8import { AttributesOnly } from '@shared/typescript-utils'
7import { createReqFiles } from '../../../helpers/express-utils' 9import { createReqFiles } from '../../../helpers/express-utils'
@@ -10,7 +12,7 @@ import { CONFIG } from '../../../initializers/config'
10import { MIMETYPES } from '../../../initializers/constants' 12import { MIMETYPES } from '../../../initializers/constants'
11import { sequelizeTypescript } from '../../../initializers/database' 13import { sequelizeTypescript } from '../../../initializers/database'
12import { sendUpdateActor } from '../../../lib/activitypub/send' 14import { sendUpdateActor } from '../../../lib/activitypub/send'
13import { deleteLocalActorImageFile, updateLocalActorImageFile } from '../../../lib/local-actor' 15import { deleteLocalActorImageFile, updateLocalActorImageFiles } from '../../../lib/local-actor'
14import { getOriginalVideoFileTotalDailyFromUser, getOriginalVideoFileTotalFromUser, sendVerifyUserEmail } from '../../../lib/user' 16import { getOriginalVideoFileTotalDailyFromUser, getOriginalVideoFileTotalFromUser, sendVerifyUserEmail } from '../../../lib/user'
15import { 17import {
16 asyncMiddleware, 18 asyncMiddleware,
@@ -30,7 +32,6 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat
30import { UserModel } from '../../../models/user/user' 32import { UserModel } from '../../../models/user/user'
31import { VideoModel } from '../../../models/video/video' 33import { VideoModel } from '../../../models/video/video'
32import { VideoImportModel } from '../../../models/video/video-import' 34import { VideoImportModel } from '../../../models/video/video-import'
33import { pick } from '@shared/core-utils'
34 35
35const auditLogger = auditLoggerFactory('users') 36const 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
261async function deleteMyAvatar (req: express.Request, res: express.Response) { 270async 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}