From 9b474844e85cce916370693cc24f53339a695570 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 19 Jul 2019 10:37:35 +0200 Subject: Add CLI plugins tests --- shared/extra-utils/users/users.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'shared/extra-utils') diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts index 5fa8cde0c..30ed1bf4a 100644 --- a/shared/extra-utils/users/users.ts +++ b/shared/extra-utils/users/users.ts @@ -6,6 +6,7 @@ import { UserRegister } from '../../models/users/user-register.model' import { UserRole } from '../../models/users/user-role' import { ServerInfo } from '../server/servers' import { userLogin } from './login' +import { UserUpdateMe } from '../../models/users' type CreateUserArgs = { url: string, accessToken: string, @@ -224,19 +225,21 @@ function updateMyUser (options: { displayName?: string description?: string videosHistoryEnabled?: boolean + theme?: string }) { const path = '/api/v1/users/me' - const toSend = {} - if (options.currentPassword !== undefined && options.currentPassword !== null) toSend['currentPassword'] = options.currentPassword - if (options.newPassword !== undefined && options.newPassword !== null) toSend['password'] = options.newPassword - if (options.nsfwPolicy !== undefined && options.nsfwPolicy !== null) toSend['nsfwPolicy'] = options.nsfwPolicy - if (options.autoPlayVideo !== undefined && options.autoPlayVideo !== null) toSend['autoPlayVideo'] = options.autoPlayVideo - if (options.email !== undefined && options.email !== null) toSend['email'] = options.email - if (options.description !== undefined && options.description !== null) toSend['description'] = options.description - if (options.displayName !== undefined && options.displayName !== null) toSend['displayName'] = options.displayName + const toSend: UserUpdateMe = {} + if (options.currentPassword !== undefined && options.currentPassword !== null) toSend.currentPassword = options.currentPassword + if (options.newPassword !== undefined && options.newPassword !== null) toSend.password = options.newPassword + if (options.nsfwPolicy !== undefined && options.nsfwPolicy !== null) toSend.nsfwPolicy = options.nsfwPolicy + if (options.autoPlayVideo !== undefined && options.autoPlayVideo !== null) toSend.autoPlayVideo = options.autoPlayVideo + if (options.email !== undefined && options.email !== null) toSend.email = options.email + if (options.description !== undefined && options.description !== null) toSend.description = options.description + if (options.displayName !== undefined && options.displayName !== null) toSend.displayName = options.displayName + if (options.theme !== undefined && options.theme !== null) toSend.theme = options.theme if (options.videosHistoryEnabled !== undefined && options.videosHistoryEnabled !== null) { - toSend['videosHistoryEnabled'] = options.videosHistoryEnabled + toSend.videosHistoryEnabled = options.videosHistoryEnabled } return makePutBodyRequest({ -- cgit v1.2.3