From 43d0ea7f4b88d52097172cc0c1831edd7e492503 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 28 Aug 2019 14:40:06 +0200 Subject: Add welcome modal --- server/controllers/api/users/me.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'server/controllers/api/users/me.ts') 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) // We did not load channels in res.locals.user const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username) - return res.json(user.toFormattedJSON({})) + return res.json(user.toFormattedJSON()) } async function getUserVideoQuotaUsed (req: express.Request, res: express.Response) { @@ -178,6 +178,8 @@ async function updateMe (req: express.Request, res: express.Response) { if (body.videosHistoryEnabled !== undefined) user.videosHistoryEnabled = body.videosHistoryEnabled if (body.videoLanguages !== undefined) user.videoLanguages = body.videoLanguages if (body.theme !== undefined) user.theme = body.theme + if (body.noInstanceConfigWarningModal !== undefined) user.noInstanceConfigWarningModal = body.noInstanceConfigWarningModal + if (body.noWelcomeModal !== undefined) user.noWelcomeModal = body.noWelcomeModal if (body.email !== undefined) { if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) { @@ -188,17 +190,19 @@ async function updateMe (req: express.Request, res: express.Response) { } } - await sequelizeTypescript.transaction(async t => { - const userAccount = await AccountModel.load(user.Account.id) + if (body.displayName !== undefined || body.description !== undefined) { + await sequelizeTypescript.transaction(async t => { + const userAccount = await AccountModel.load(user.Account.id, t) - await user.save({ transaction: t }) + await user.save({ transaction: t }) - if (body.displayName !== undefined) userAccount.name = body.displayName - if (body.description !== undefined) userAccount.description = body.description - await userAccount.save({ transaction: t }) + if (body.displayName !== undefined) userAccount.name = body.displayName + if (body.description !== undefined) userAccount.description = body.description + await userAccount.save({ transaction: t }) - await sendUpdateActor(userAccount, t) - }) + await sendUpdateActor(userAccount, t) + }) + } if (sendVerificationEmail === true) { await sendVerifyUserEmail(user, true) -- cgit v1.2.3