aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/core-utils/common/object.ts14
-rw-r--r--shared/server-commands/users/users-command.ts5
-rw-r--r--shared/server-commands/videos/live-command.ts5
-rw-r--r--shared/server-commands/videos/playlists-command.ts7
-rw-r--r--shared/server-commands/videos/videos-command.ts5
5 files changed, 23 insertions, 13 deletions
diff --git a/shared/core-utils/common/object.ts b/shared/core-utils/common/object.ts
index 49d209819..2330c9403 100644
--- a/shared/core-utils/common/object.ts
+++ b/shared/core-utils/common/object.ts
@@ -10,6 +10,19 @@ function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick
10 return result 10 return result
11} 11}
12 12
13function omit <O extends object, K extends keyof O> (object: O, keys: K[]): Exclude<O, K> {
14 const result: any = {}
15 const keysSet = new Set(keys) as Set<string>
16
17 for (const [ key, value ] of Object.entries(object)) {
18 if (keysSet.has(key)) continue
19
20 result[key] = value
21 }
22
23 return result
24}
25
13function getKeys <O extends object, K extends keyof O> (object: O, keys: K[]): K[] { 26function getKeys <O extends object, K extends keyof O> (object: O, keys: K[]): K[] {
14 return (Object.keys(object) as K[]).filter(k => keys.includes(k)) 27 return (Object.keys(object) as K[]).filter(k => keys.includes(k))
15} 28}
@@ -30,6 +43,7 @@ function sortObjectComparator (key: string, order: 'asc' | 'desc') {
30 43
31export { 44export {
32 pick, 45 pick,
46 omit,
33 getKeys, 47 getKeys,
34 sortObjectComparator 48 sortObjectComparator
35} 49}
diff --git a/shared/server-commands/users/users-command.ts b/shared/server-commands/users/users-command.ts
index b5ae9008e..d8303848d 100644
--- a/shared/server-commands/users/users-command.ts
+++ b/shared/server-commands/users/users-command.ts
@@ -1,5 +1,4 @@
1import { omit } from 'lodash' 1import { omit, pick } from '@shared/core-utils'
2import { pick } from '@shared/core-utils'
3import { 2import {
4 HttpStatusCode, 3 HttpStatusCode,
5 MyUser, 4 MyUser,
@@ -298,7 +297,7 @@ export class UsersCommand extends AbstractCommand {
298 updateMe (options: OverrideCommandOptions & UserUpdateMe) { 297 updateMe (options: OverrideCommandOptions & UserUpdateMe) {
299 const path = '/api/v1/users/me' 298 const path = '/api/v1/users/me'
300 299
301 const toSend: UserUpdateMe = omit(options, 'url', 'accessToken') 300 const toSend: UserUpdateMe = omit(options, [ 'expectedStatus', 'token' ])
302 301
303 return this.putBodyRequest({ 302 return this.putBodyRequest({
304 ...options, 303 ...options,
diff --git a/shared/server-commands/videos/live-command.ts b/shared/server-commands/videos/live-command.ts
index 3df47ed4d..d804fd883 100644
--- a/shared/server-commands/videos/live-command.ts
+++ b/shared/server-commands/videos/live-command.ts
@@ -1,9 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import { readdir } from 'fs-extra' 3import { readdir } from 'fs-extra'
4import { omit } from 'lodash'
5import { join } from 'path' 4import { join } from 'path'
6import { wait } from '@shared/core-utils' 5import { omit, wait } from '@shared/core-utils'
7import { 6import {
8 HttpStatusCode, 7 HttpStatusCode,
9 LiveVideo, 8 LiveVideo,
@@ -103,7 +102,7 @@ export class LiveCommand extends AbstractCommand {
103 102
104 path, 103 path,
105 attaches, 104 attaches,
106 fields: omit(fields, 'thumbnailfile', 'previewfile'), 105 fields: omit(fields, [ 'thumbnailfile', 'previewfile' ]),
107 implicitToken: true, 106 implicitToken: true,
108 defaultExpectedStatus: HttpStatusCode.OK_200 107 defaultExpectedStatus: HttpStatusCode.OK_200
109 })) 108 }))
diff --git a/shared/server-commands/videos/playlists-command.ts b/shared/server-commands/videos/playlists-command.ts
index ce23900d3..516da0bf7 100644
--- a/shared/server-commands/videos/playlists-command.ts
+++ b/shared/server-commands/videos/playlists-command.ts
@@ -1,5 +1,4 @@
1import { omit } from 'lodash' 1import { omit, pick } from '@shared/core-utils'
2import { pick } from '@shared/core-utils'
3import { 2import {
4 BooleanBothQuery, 3 BooleanBothQuery,
5 HttpStatusCode, 4 HttpStatusCode,
@@ -136,7 +135,7 @@ export class PlaylistsCommand extends AbstractCommand {
136 }) { 135 }) {
137 const path = '/api/v1/video-playlists' 136 const path = '/api/v1/video-playlists'
138 137
139 const fields = omit(options.attributes, 'thumbnailfile') 138 const fields = omit(options.attributes, [ 'thumbnailfile' ])
140 139
141 const attaches = options.attributes.thumbnailfile 140 const attaches = options.attributes.thumbnailfile
142 ? { thumbnailfile: options.attributes.thumbnailfile } 141 ? { thumbnailfile: options.attributes.thumbnailfile }
@@ -161,7 +160,7 @@ export class PlaylistsCommand extends AbstractCommand {
161 }) { 160 }) {
162 const path = '/api/v1/video-playlists/' + options.playlistId 161 const path = '/api/v1/video-playlists/' + options.playlistId
163 162
164 const fields = omit(options.attributes, 'thumbnailfile') 163 const fields = omit(options.attributes, [ 'thumbnailfile' ])
165 164
166 const attaches = options.attributes.thumbnailfile 165 const attaches = options.attributes.thumbnailfile
167 ? { thumbnailfile: options.attributes.thumbnailfile } 166 ? { thumbnailfile: options.attributes.thumbnailfile }
diff --git a/shared/server-commands/videos/videos-command.ts b/shared/server-commands/videos/videos-command.ts
index c0b36d95b..168391523 100644
--- a/shared/server-commands/videos/videos-command.ts
+++ b/shared/server-commands/videos/videos-command.ts
@@ -3,9 +3,8 @@
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { createReadStream, stat } from 'fs-extra' 4import { createReadStream, stat } from 'fs-extra'
5import got, { Response as GotResponse } from 'got' 5import got, { Response as GotResponse } from 'got'
6import { omit } from 'lodash'
7import validator from 'validator' 6import validator from 'validator'
8import { buildAbsoluteFixturePath, pick, wait } from '@shared/core-utils' 7import { buildAbsoluteFixturePath, omit, pick, wait } from '@shared/core-utils'
9import { buildUUID } from '@shared/extra-utils' 8import { buildUUID } from '@shared/extra-utils'
10import { 9import {
11 HttpStatusCode, 10 HttpStatusCode,
@@ -484,7 +483,7 @@ export class VideosCommand extends AbstractCommand {
484 }, 483 },
485 484
486 // Fixture will be sent later 485 // Fixture will be sent later
487 attaches: this.buildUploadAttaches(omit(options.attributes, 'fixture')), 486 attaches: this.buildUploadAttaches(omit(options.attributes, [ 'fixture' ])),
488 implicitToken: true, 487 implicitToken: true,
489 488
490 defaultExpectedStatus: null 489 defaultExpectedStatus: null