]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/users.ts
Add ability to update the user display name/description
[github/Chocobozzz/PeerTube.git] / server / controllers / api / users.ts
index 6540adb1c1a797f9199a9309bdbc2258bf5c58bd..2342c23dd683b809ba9db028907033cb382ed04d 100644 (file)
@@ -7,7 +7,7 @@ import { UserCreate, UserRight, UserRole, UserUpdate, UserUpdateMe, UserVideoRat
 import { retryTransactionWrapper } from '../../helpers/database-utils'
 import { processImage } from '../../helpers/image-utils'
 import { logger } from '../../helpers/logger'
-import { createReqFiles, getFormattedObjects } from '../../helpers/utils'
+import { getFormattedObjects } from '../../helpers/utils'
 import { AVATARS_SIZE, CONFIG, IMAGE_MIMETYPE_EXT, RATES_LIMIT, sequelizeTypescript } from '../../initializers'
 import { updateActorAvatarInstance } from '../../lib/activitypub'
 import { sendUpdateActor } from '../../lib/activitypub/send'
@@ -43,6 +43,7 @@ import { UserModel } from '../../models/account/user'
 import { OAuthTokenModel } from '../../models/oauth/oauth-token'
 import { VideoModel } from '../../models/video/video'
 import { VideoSortField } from '../../../client/src/app/shared/video/sort-field.type'
+import { createReqFiles } from '../../helpers/express-utils'
 
 const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR })
 const loginRateLimiter = new RateLimit({
@@ -184,7 +185,10 @@ async function createUserRetryWrapper (req: express.Request, res: express.Respon
   return res.json({
     user: {
       id: user.id,
-      uuid: account.uuid
+      account: {
+        id: account.id,
+        uuid: account.Actor.uuid
+      }
     }
   }).end()
 }
@@ -299,6 +303,7 @@ async function updateMe (req: express.Request, res: express.Response, next: expr
   await sequelizeTypescript.transaction(async t => {
     await user.save({ transaction: t })
 
+    if (body.displayName !== undefined) user.Account.name = body.displayName
     if (body.description !== undefined) user.Account.description = body.description
     await user.Account.save({ transaction: t })