aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/users')
-rw-r--r--server/controllers/api/users/me.ts19
-rw-r--r--server/controllers/api/users/my-notifications.ts2
2 files changed, 15 insertions, 6 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}
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'
3import { UserNotificationModel } from '@server/models/user/user-notification' 3import { UserNotificationModel } from '@server/models/user/user-notification'
4import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 4import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
5import { UserNotificationSetting } from '../../../../shared/models/users' 5import { UserNotificationSetting } from '../../../../shared/models/users'
6import { getFormattedObjects } from '../../../helpers/utils'
7import { 6import {
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'
21import { UserNotificationSettingModel } from '../../../models/user/user-notification-setting' 20import { UserNotificationSettingModel } from '../../../models/user/user-notification-setting'
22import { meRouter } from './me' 21import { meRouter } from './me'
22import { getFormattedObjects } from '@server/helpers/utils'
23 23
24const myNotificationsRouter = express.Router() 24const myNotificationsRouter = express.Router()
25 25