aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/users/me.ts22
1 files changed, 13 insertions, 9 deletions
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts
index 78e1e7fa3..fb1ddbc6d 100644
--- a/server/controllers/api/users/me.ts
+++ b/server/controllers/api/users/me.ts
@@ -127,7 +127,7 @@ async function getUserInformation (req: express.Request, res: express.Response)
127 // We did not load channels in res.locals.user 127 // We did not load channels in res.locals.user
128 const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username) 128 const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
129 129
130 return res.json(user.toFormattedJSON({})) 130 return res.json(user.toFormattedJSON())
131} 131}
132 132
133async function getUserVideoQuotaUsed (req: express.Request, res: express.Response) { 133async function getUserVideoQuotaUsed (req: express.Request, res: express.Response) {
@@ -178,6 +178,8 @@ async function updateMe (req: express.Request, res: express.Response) {
178 if (body.videosHistoryEnabled !== undefined) user.videosHistoryEnabled = body.videosHistoryEnabled 178 if (body.videosHistoryEnabled !== undefined) user.videosHistoryEnabled = body.videosHistoryEnabled
179 if (body.videoLanguages !== undefined) user.videoLanguages = body.videoLanguages 179 if (body.videoLanguages !== undefined) user.videoLanguages = body.videoLanguages
180 if (body.theme !== undefined) user.theme = body.theme 180 if (body.theme !== undefined) user.theme = body.theme
181 if (body.noInstanceConfigWarningModal !== undefined) user.noInstanceConfigWarningModal = body.noInstanceConfigWarningModal
182 if (body.noWelcomeModal !== undefined) user.noWelcomeModal = body.noWelcomeModal
181 183
182 if (body.email !== undefined) { 184 if (body.email !== undefined) {
183 if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) { 185 if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) {
@@ -188,17 +190,19 @@ async function updateMe (req: express.Request, res: express.Response) {
188 } 190 }
189 } 191 }
190 192
191 await sequelizeTypescript.transaction(async t => { 193 if (body.displayName !== undefined || body.description !== undefined) {
192 const userAccount = await AccountModel.load(user.Account.id) 194 await sequelizeTypescript.transaction(async t => {
195 const userAccount = await AccountModel.load(user.Account.id, t)
193 196
194 await user.save({ transaction: t }) 197 await user.save({ transaction: t })
195 198
196 if (body.displayName !== undefined) userAccount.name = body.displayName 199 if (body.displayName !== undefined) userAccount.name = body.displayName
197 if (body.description !== undefined) userAccount.description = body.description 200 if (body.description !== undefined) userAccount.description = body.description
198 await userAccount.save({ transaction: t }) 201 await userAccount.save({ transaction: t })
199 202
200 await sendUpdateActor(userAccount, t) 203 await sendUpdateActor(userAccount, t)
201 }) 204 })
205 }
202 206
203 if (sendVerificationEmail === true) { 207 if (sendVerificationEmail === true) {
204 await sendVerifyUserEmail(user, true) 208 await sendVerifyUserEmail(user, true)