diff options
Diffstat (limited to 'shared')
-rw-r--r-- | shared/core-utils/index.ts | 1 | ||||
-rw-r--r-- | shared/core-utils/utils/index.ts | 1 | ||||
-rw-r--r-- | shared/core-utils/utils/object.ts | 15 | ||||
-rw-r--r-- | shared/extra-utils/moderation/abuses-command.ts | 6 | ||||
-rw-r--r-- | shared/extra-utils/server/follows-command.ts | 8 | ||||
-rw-r--r-- | shared/extra-utils/server/jobs-command.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/users/users-command.ts | 3 | ||||
-rw-r--r-- | shared/extra-utils/videos/channels-command.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/videos/playlists-command.ts | 3 | ||||
-rw-r--r-- | shared/extra-utils/videos/videos-command.ts | 3 | ||||
-rw-r--r-- | shared/models/search/video-channels-search-query.model.ts | 2 |
11 files changed, 32 insertions, 14 deletions
diff --git a/shared/core-utils/index.ts b/shared/core-utils/index.ts index 66d50ef93..2a7d4d982 100644 --- a/shared/core-utils/index.ts +++ b/shared/core-utils/index.ts | |||
@@ -4,3 +4,4 @@ export * from './i18n' | |||
4 | export * from './plugins' | 4 | export * from './plugins' |
5 | export * from './renderer' | 5 | export * from './renderer' |
6 | export * from './users' | 6 | export * from './users' |
7 | export * from './utils' | ||
diff --git a/shared/core-utils/utils/index.ts b/shared/core-utils/utils/index.ts new file mode 100644 index 000000000..a71977d88 --- /dev/null +++ b/shared/core-utils/utils/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './object' | |||
diff --git a/shared/core-utils/utils/object.ts b/shared/core-utils/utils/object.ts new file mode 100644 index 000000000..7b2bb81d0 --- /dev/null +++ b/shared/core-utils/utils/object.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | function pick <T extends object> (object: T, keys: (keyof T)[]) { | ||
2 | const result: Partial<T> = {} | ||
3 | |||
4 | for (const key of keys) { | ||
5 | if (Object.prototype.hasOwnProperty.call(object, key)) { | ||
6 | result[key] = object[key] | ||
7 | } | ||
8 | } | ||
9 | |||
10 | return result | ||
11 | } | ||
12 | |||
13 | export { | ||
14 | pick | ||
15 | } | ||
diff --git a/shared/extra-utils/moderation/abuses-command.ts b/shared/extra-utils/moderation/abuses-command.ts index 7b3abb056..0db32ba46 100644 --- a/shared/extra-utils/moderation/abuses-command.ts +++ b/shared/extra-utils/moderation/abuses-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { pick } from 'lodash' | 1 | import { pick } from '@shared/core-utils' |
2 | import { | 2 | import { |
3 | AbuseFilter, | 3 | AbuseFilter, |
4 | AbuseMessage, | 4 | AbuseMessage, |
@@ -81,7 +81,7 @@ export class AbusesCommand extends AbstractCommand { | |||
81 | searchVideo?: string | 81 | searchVideo?: string |
82 | searchVideoChannel?: string | 82 | searchVideoChannel?: string |
83 | } = {}) { | 83 | } = {}) { |
84 | const toPick = [ | 84 | const toPick: (keyof typeof options)[] = [ |
85 | 'count', | 85 | 'count', |
86 | 'filter', | 86 | 'filter', |
87 | 'id', | 87 | 'id', |
@@ -121,7 +121,7 @@ export class AbusesCommand extends AbstractCommand { | |||
121 | search?: string | 121 | search?: string |
122 | state?: AbuseState | 122 | state?: AbuseState |
123 | }) { | 123 | }) { |
124 | const toPick = [ | 124 | const toPick: (keyof typeof options)[] = [ |
125 | 'id', | 125 | 'id', |
126 | 'search', | 126 | 'search', |
127 | 'state', | 127 | 'state', |
diff --git a/shared/extra-utils/server/follows-command.ts b/shared/extra-utils/server/follows-command.ts index 2b889cf66..01ef6f179 100644 --- a/shared/extra-utils/server/follows-command.ts +++ b/shared/extra-utils/server/follows-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { pick } from 'lodash' | 1 | import { pick } from '@shared/core-utils' |
2 | import { ActivityPubActorType, ActorFollow, FollowState, HttpStatusCode, ResultList, ServerFollowCreate } from '@shared/models' | 2 | import { ActivityPubActorType, ActorFollow, FollowState, HttpStatusCode, ResultList, ServerFollowCreate } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | import { PeerTubeServer } from './server' | 4 | import { PeerTubeServer } from './server' |
@@ -15,8 +15,7 @@ export class FollowsCommand extends AbstractCommand { | |||
15 | }) { | 15 | }) { |
16 | const path = '/api/v1/server/followers' | 16 | const path = '/api/v1/server/followers' |
17 | 17 | ||
18 | const toPick = [ 'start', 'count', 'sort', 'search', 'state', 'actorType' ] | 18 | const query = pick(options, [ 'start', 'count', 'sort', 'search', 'state', 'actorType' ]) |
19 | const query = pick(options, toPick) | ||
20 | 19 | ||
21 | return this.getRequestBody<ResultList<ActorFollow>>({ | 20 | return this.getRequestBody<ResultList<ActorFollow>>({ |
22 | ...options, | 21 | ...options, |
@@ -38,8 +37,7 @@ export class FollowsCommand extends AbstractCommand { | |||
38 | } = {}) { | 37 | } = {}) { |
39 | const path = '/api/v1/server/following' | 38 | const path = '/api/v1/server/following' |
40 | 39 | ||
41 | const toPick = [ 'start', 'count', 'sort', 'search', 'state', 'actorType' ] | 40 | const query = pick(options, [ 'start', 'count', 'sort', 'search', 'state', 'actorType' ]) |
42 | const query = pick(options, toPick) | ||
43 | 41 | ||
44 | return this.getRequestBody<ResultList<ActorFollow>>({ | 42 | return this.getRequestBody<ResultList<ActorFollow>>({ |
45 | ...options, | 43 | ...options, |
diff --git a/shared/extra-utils/server/jobs-command.ts b/shared/extra-utils/server/jobs-command.ts index 09a299e5b..c4eb12dc2 100644 --- a/shared/extra-utils/server/jobs-command.ts +++ b/shared/extra-utils/server/jobs-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { pick } from 'lodash' | 1 | import { pick } from '@shared/core-utils' |
2 | import { HttpStatusCode } from '@shared/models' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { Job, JobState, JobType, ResultList } from '../../models' | 3 | import { Job, JobState, JobType, ResultList } from '../../models' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
diff --git a/shared/extra-utils/users/users-command.ts b/shared/extra-utils/users/users-command.ts index d66ad15f2..ddd20d041 100644 --- a/shared/extra-utils/users/users-command.ts +++ b/shared/extra-utils/users/users-command.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { omit, pick } from 'lodash' | 1 | import { omit } from 'lodash' |
2 | import { pick } from '@shared/core-utils' | ||
2 | import { | 3 | import { |
3 | HttpStatusCode, | 4 | HttpStatusCode, |
4 | MyUser, | 5 | MyUser, |
diff --git a/shared/extra-utils/videos/channels-command.ts b/shared/extra-utils/videos/channels-command.ts index f8eb3f885..255e1d62d 100644 --- a/shared/extra-utils/videos/channels-command.ts +++ b/shared/extra-utils/videos/channels-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { pick } from 'lodash' | 1 | import { pick } from '@shared/core-utils' |
2 | import { HttpStatusCode, ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models' | 2 | import { HttpStatusCode, ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models' |
3 | import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' | 3 | import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' |
4 | import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' | 4 | import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' |
diff --git a/shared/extra-utils/videos/playlists-command.ts b/shared/extra-utils/videos/playlists-command.ts index 6f329800e..ce23900d3 100644 --- a/shared/extra-utils/videos/playlists-command.ts +++ b/shared/extra-utils/videos/playlists-command.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { omit, pick } from 'lodash' | 1 | import { omit } from 'lodash' |
2 | import { pick } from '@shared/core-utils' | ||
2 | import { | 3 | import { |
3 | BooleanBothQuery, | 4 | BooleanBothQuery, |
4 | HttpStatusCode, | 5 | HttpStatusCode, |
diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts index 98465e8f6..33725bfdc 100644 --- a/shared/extra-utils/videos/videos-command.ts +++ b/shared/extra-utils/videos/videos-command.ts | |||
@@ -3,10 +3,11 @@ | |||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { createReadStream, stat } from 'fs-extra' | 4 | import { createReadStream, stat } from 'fs-extra' |
5 | import got, { Response as GotResponse } from 'got' | 5 | import got, { Response as GotResponse } from 'got' |
6 | import { omit, pick } from 'lodash' | 6 | import { omit } from 'lodash' |
7 | import validator from 'validator' | 7 | import validator from 'validator' |
8 | import { buildUUID } from '@server/helpers/uuid' | 8 | import { buildUUID } from '@server/helpers/uuid' |
9 | import { loadLanguages } from '@server/initializers/constants' | 9 | import { loadLanguages } from '@server/initializers/constants' |
10 | import { pick } from '@shared/core-utils' | ||
10 | import { | 11 | import { |
11 | HttpStatusCode, | 12 | HttpStatusCode, |
12 | ResultList, | 13 | ResultList, |
diff --git a/shared/models/search/video-channels-search-query.model.ts b/shared/models/search/video-channels-search-query.model.ts index 50c59d41d..77cea4a59 100644 --- a/shared/models/search/video-channels-search-query.model.ts +++ b/shared/models/search/video-channels-search-query.model.ts | |||
@@ -8,5 +8,5 @@ export interface VideoChannelsSearchQuery extends SearchTargetQuery { | |||
8 | sort?: string | 8 | sort?: string |
9 | 9 | ||
10 | host?: string | 10 | host?: string |
11 | names?: string[] | 11 | handles?: string[] |
12 | } | 12 | } |