diff options
Diffstat (limited to 'shared/extra-utils')
-rw-r--r-- | shared/extra-utils/users/users.ts | 29 |
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 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' | 2 | import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' |
3 | import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type' | ||
4 | import { UserAdminFlag } from '../../models/users/user-flag.model' | 3 | import { UserAdminFlag } from '../../models/users/user-flag.model' |
5 | import { UserRegister } from '../../models/users/user-register.model' | 4 | import { UserRegister } from '../../models/users/user-register.model' |
6 | import { UserRole } from '../../models/users/user-role' | 5 | import { UserRole } from '../../models/users/user-role' |
7 | import { ServerInfo } from '../server/servers' | 6 | import { ServerInfo } from '../server/servers' |
8 | import { userLogin } from './login' | 7 | import { userLogin } from './login' |
9 | import { UserUpdateMe } from '../../models/users' | 8 | import { UserUpdateMe } from '../../models/users' |
9 | import { omit } from 'lodash' | ||
10 | 10 | ||
11 | type CreateUserArgs = { url: string, | 11 | type 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 | ||
217 | function updateMyUser (options: { | 217 | function 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, |