diff options
Diffstat (limited to 'shared/extra-utils')
-rw-r--r-- | shared/extra-utils/bulk/bulk.ts | 24 | ||||
-rw-r--r-- | shared/extra-utils/index.ts | 1 | ||||
-rw-r--r-- | shared/extra-utils/server/config.ts | 6 | ||||
-rw-r--r-- | shared/extra-utils/videos/video-comments.ts | 7 | ||||
-rw-r--r-- | shared/extra-utils/videos/videos.ts | 9 |
5 files changed, 46 insertions, 1 deletions
diff --git a/shared/extra-utils/bulk/bulk.ts b/shared/extra-utils/bulk/bulk.ts new file mode 100644 index 000000000..d6798ceb7 --- /dev/null +++ b/shared/extra-utils/bulk/bulk.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | import { BulkRemoveCommentsOfBody } from "@shared/models/bulk/bulk-remove-comments-of-body.model" | ||
2 | import { makePostBodyRequest } from "../requests/requests" | ||
3 | |||
4 | function bulkRemoveCommentsOf (options: { | ||
5 | url: string | ||
6 | token: string | ||
7 | attributes: BulkRemoveCommentsOfBody | ||
8 | expectedStatus?: number | ||
9 | }) { | ||
10 | const { url, token, attributes, expectedStatus } = options | ||
11 | const path = '/api/v1/bulk/remove-comments-of' | ||
12 | |||
13 | return makePostBodyRequest({ | ||
14 | url, | ||
15 | path, | ||
16 | token, | ||
17 | fields: attributes, | ||
18 | statusCodeExpected: expectedStatus || 204 | ||
19 | }) | ||
20 | } | ||
21 | |||
22 | export { | ||
23 | bulkRemoveCommentsOf | ||
24 | } | ||
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts index d3f010b20..2ac0c6338 100644 --- a/shared/extra-utils/index.ts +++ b/shared/extra-utils/index.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | export * from './server/activitypub' | 1 | export * from './server/activitypub' |
2 | export * from './bulk/bulk' | ||
2 | export * from './cli/cli' | 3 | export * from './cli/cli' |
3 | export * from './server/clients' | 4 | export * from './server/clients' |
4 | export * from './server/config' | 5 | export * from './server/config' |
diff --git a/shared/extra-utils/server/config.ts b/shared/extra-utils/server/config.ts index 743d10316..98cd435f6 100644 --- a/shared/extra-utils/server/config.ts +++ b/shared/extra-utils/server/config.ts | |||
@@ -159,6 +159,12 @@ function updateCustomSubConfig (url: string, token: string, newConfig: DeepParti | |||
159 | enabled: false | 159 | enabled: false |
160 | } | 160 | } |
161 | } | 161 | } |
162 | }, | ||
163 | broadcastMessage: { | ||
164 | enabled: true, | ||
165 | level: 'warning', | ||
166 | message: 'hello', | ||
167 | dismissable: true | ||
162 | } | 168 | } |
163 | } | 169 | } |
164 | 170 | ||
diff --git a/shared/extra-utils/videos/video-comments.ts b/shared/extra-utils/videos/video-comments.ts index 81c48412d..831e5e7d4 100644 --- a/shared/extra-utils/videos/video-comments.ts +++ b/shared/extra-utils/videos/video-comments.ts | |||
@@ -61,6 +61,12 @@ function addVideoCommentReply ( | |||
61 | .expect(expectedStatus) | 61 | .expect(expectedStatus) |
62 | } | 62 | } |
63 | 63 | ||
64 | async function findCommentId (url: string, videoId: number | string, text: string) { | ||
65 | const res = await getVideoCommentThreads(url, videoId, 0, 25, '-createdAt') | ||
66 | |||
67 | return res.body.data.find(c => c.text === text).id as number | ||
68 | } | ||
69 | |||
64 | function deleteVideoComment ( | 70 | function deleteVideoComment ( |
65 | url: string, | 71 | url: string, |
66 | token: string, | 72 | token: string, |
@@ -85,5 +91,6 @@ export { | |||
85 | getVideoThreadComments, | 91 | getVideoThreadComments, |
86 | addVideoCommentThread, | 92 | addVideoCommentThread, |
87 | addVideoCommentReply, | 93 | addVideoCommentReply, |
94 | findCommentId, | ||
88 | deleteVideoComment | 95 | deleteVideoComment |
89 | } | 96 | } |
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index 0d36a38a2..99e591cb2 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts | |||
@@ -95,6 +95,12 @@ function getVideo (url: string, id: number | string, expectedStatus = 200) { | |||
95 | .expect(expectedStatus) | 95 | .expect(expectedStatus) |
96 | } | 96 | } |
97 | 97 | ||
98 | async function getVideoIdFromUUID (url: string, uuid: string) { | ||
99 | const res = await getVideo(url, uuid) | ||
100 | |||
101 | return res.body.id | ||
102 | } | ||
103 | |||
98 | function getVideoFileMetadataUrl (url: string) { | 104 | function getVideoFileMetadataUrl (url: string) { |
99 | return request(url) | 105 | return request(url) |
100 | .get('/') | 106 | .get('/') |
@@ -669,5 +675,6 @@ export { | |||
669 | checkVideoFilesWereRemoved, | 675 | checkVideoFilesWereRemoved, |
670 | getPlaylistVideos, | 676 | getPlaylistVideos, |
671 | uploadVideoAndGetId, | 677 | uploadVideoAndGetId, |
672 | getLocalIdByUUID | 678 | getLocalIdByUUID, |
679 | getVideoIdFromUUID | ||
673 | } | 680 | } |