aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/users
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/users')
-rw-r--r--shared/extra-utils/users/users.ts29
1 files changed, 3 insertions, 26 deletions
diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts
index 30ed1bf4a..9959fd074 100644
--- a/shared/extra-utils/users/users.ts
+++ b/shared/extra-utils/users/users.ts
@@ -1,12 +1,12 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' 2import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests'
3import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type'
4import { UserAdminFlag } from '../../models/users/user-flag.model' 3import { UserAdminFlag } from '../../models/users/user-flag.model'
5import { UserRegister } from '../../models/users/user-register.model' 4import { UserRegister } from '../../models/users/user-register.model'
6import { UserRole } from '../../models/users/user-role' 5import { UserRole } from '../../models/users/user-role'
7import { ServerInfo } from '../server/servers' 6import { ServerInfo } from '../server/servers'
8import { userLogin } from './login' 7import { userLogin } from './login'
9import { UserUpdateMe } from '../../models/users' 8import { UserUpdateMe } from '../../models/users'
9import { omit } from 'lodash'
10 10
11type CreateUserArgs = { url: string, 11type CreateUserArgs = { url: string,
12 accessToken: string, 12 accessToken: string,
@@ -214,33 +214,10 @@ function unblockUser (url: string, userId: number | string, accessToken: string,
214 .expect(expectedStatus) 214 .expect(expectedStatus)
215} 215}
216 216
217function updateMyUser (options: { 217function updateMyUser (options: { url: string, accessToken: string } & UserUpdateMe) {
218 url: string
219 accessToken: string
220 currentPassword?: string
221 newPassword?: string
222 nsfwPolicy?: NSFWPolicyType
223 email?: string
224 autoPlayVideo?: boolean
225 displayName?: string
226 description?: string
227 videosHistoryEnabled?: boolean
228 theme?: string
229}) {
230 const path = '/api/v1/users/me' 218 const path = '/api/v1/users/me'
231 219
232 const toSend: UserUpdateMe = {} 220 const toSend: UserUpdateMe = omit(options, 'url', 'accessToken')
233 if (options.currentPassword !== undefined && options.currentPassword !== null) toSend.currentPassword = options.currentPassword
234 if (options.newPassword !== undefined && options.newPassword !== null) toSend.password = options.newPassword
235 if (options.nsfwPolicy !== undefined && options.nsfwPolicy !== null) toSend.nsfwPolicy = options.nsfwPolicy
236 if (options.autoPlayVideo !== undefined && options.autoPlayVideo !== null) toSend.autoPlayVideo = options.autoPlayVideo
237 if (options.email !== undefined && options.email !== null) toSend.email = options.email
238 if (options.description !== undefined && options.description !== null) toSend.description = options.description
239 if (options.displayName !== undefined && options.displayName !== null) toSend.displayName = options.displayName
240 if (options.theme !== undefined && options.theme !== null) toSend.theme = options.theme
241 if (options.videosHistoryEnabled !== undefined && options.videosHistoryEnabled !== null) {
242 toSend.videosHistoryEnabled = options.videosHistoryEnabled
243 }
244 221
245 return makePutBodyRequest({ 222 return makePutBodyRequest({
246 url: options.url, 223 url: options.url,