aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-08 10:55:16 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commita1637fa1e25b60a88f7cfe50aac8953f50d55761 (patch)
tree4d0cc82eef618619a7bcb747812cc7b21e0d8776 /shared
parent04aed76711909507e74905bde3a7fa024d3585c9 (diff)
downloadPeerTube-a1637fa1e25b60a88f7cfe50aac8953f50d55761.tar.gz
PeerTube-a1637fa1e25b60a88f7cfe50aac8953f50d55761.tar.zst
PeerTube-a1637fa1e25b60a88f7cfe50aac8953f50d55761.zip
Specify if we want to fallback to the server token
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/bulk/bulk-command.ts2
-rw-r--r--shared/extra-utils/custom-pages/custom-pages-command.ts4
-rw-r--r--shared/extra-utils/feeds/feeds-command.ts2
-rw-r--r--shared/extra-utils/logs/logs-command.ts2
-rw-r--r--shared/extra-utils/moderation/abuses-command.ts29
-rw-r--r--shared/extra-utils/overviews/overviews-command.ts4
-rw-r--r--shared/extra-utils/search/search-command.ts15
-rw-r--r--shared/extra-utils/server/config-command.ts7
-rw-r--r--shared/extra-utils/server/contact-form-command.ts2
-rw-r--r--shared/extra-utils/server/debug-command.ts2
-rw-r--r--shared/extra-utils/server/follows-command.ts11
-rw-r--r--shared/extra-utils/server/jobs-command.ts1
-rw-r--r--shared/extra-utils/server/plugins-command.ts12
-rw-r--r--shared/extra-utils/server/redundancy-command.ts4
-rw-r--r--shared/extra-utils/server/stats-command.ts1
-rw-r--r--shared/extra-utils/shared/abstract-command.ts41
-rw-r--r--shared/extra-utils/users/accounts-command.ts3
-rw-r--r--shared/extra-utils/users/blocklist-command.ts5
-rw-r--r--shared/extra-utils/users/subscriptions-command.ts6
-rw-r--r--shared/extra-utils/videos/live-command.ts3
-rw-r--r--shared/extra-utils/videos/services-command.ts1
21 files changed, 122 insertions, 35 deletions
diff --git a/shared/extra-utils/bulk/bulk-command.ts b/shared/extra-utils/bulk/bulk-command.ts
index fcbf04164..6dac6034f 100644
--- a/shared/extra-utils/bulk/bulk-command.ts
+++ b/shared/extra-utils/bulk/bulk-command.ts
@@ -12,8 +12,10 @@ export class BulkCommand extends AbstractCommand {
12 12
13 return this.postBodyRequest({ 13 return this.postBodyRequest({
14 ...options, 14 ...options,
15
15 path: '/api/v1/bulk/remove-comments-of', 16 path: '/api/v1/bulk/remove-comments-of',
16 fields: attributes, 17 fields: attributes,
18 implicitToken: true,
17 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 19 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
18 }) 20 })
19 } 21 }
diff --git a/shared/extra-utils/custom-pages/custom-pages-command.ts b/shared/extra-utils/custom-pages/custom-pages-command.ts
index a062c9774..0dd77503e 100644
--- a/shared/extra-utils/custom-pages/custom-pages-command.ts
+++ b/shared/extra-utils/custom-pages/custom-pages-command.ts
@@ -9,7 +9,9 @@ export class CustomPagesCommand extends AbstractCommand {
9 9
10 return this.getRequestBody<CustomPage>({ 10 return this.getRequestBody<CustomPage>({
11 ...options, 11 ...options,
12
12 path, 13 path,
14 implicitToken: false,
13 defaultExpectedStatus: HttpStatusCode.OK_200 15 defaultExpectedStatus: HttpStatusCode.OK_200
14 }) 16 })
15 } 17 }
@@ -22,8 +24,10 @@ export class CustomPagesCommand extends AbstractCommand {
22 24
23 return this.putBodyRequest({ 25 return this.putBodyRequest({
24 ...options, 26 ...options,
27
25 path, 28 path,
26 fields: { content }, 29 fields: { content },
30 implicitToken: true,
27 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 31 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
28 }) 32 })
29 } 33 }
diff --git a/shared/extra-utils/feeds/feeds-command.ts b/shared/extra-utils/feeds/feeds-command.ts
index 8031adf92..2da4110a7 100644
--- a/shared/extra-utils/feeds/feeds-command.ts
+++ b/shared/extra-utils/feeds/feeds-command.ts
@@ -19,6 +19,7 @@ export class FeedCommand extends AbstractCommand {
19 path, 19 path,
20 query: format ? { format } : undefined, 20 query: format ? { format } : undefined,
21 accept: 'application/xml', 21 accept: 'application/xml',
22 implicitToken: false,
22 defaultExpectedStatus: HttpStatusCode.OK_200 23 defaultExpectedStatus: HttpStatusCode.OK_200
23 }) 24 })
24 } 25 }
@@ -36,6 +37,7 @@ export class FeedCommand extends AbstractCommand {
36 path, 37 path,
37 query, 38 query,
38 accept: 'application/json', 39 accept: 'application/json',
40 implicitToken: false,
39 defaultExpectedStatus: HttpStatusCode.OK_200 41 defaultExpectedStatus: HttpStatusCode.OK_200
40 }) 42 })
41 } 43 }
diff --git a/shared/extra-utils/logs/logs-command.ts b/shared/extra-utils/logs/logs-command.ts
index f7594734d..f34c58c47 100644
--- a/shared/extra-utils/logs/logs-command.ts
+++ b/shared/extra-utils/logs/logs-command.ts
@@ -17,6 +17,7 @@ export class LogsCommand extends AbstractCommand {
17 17
18 path, 18 path,
19 query: { startDate, endDate, level }, 19 query: { startDate, endDate, level },
20 implicitToken: true,
20 defaultExpectedStatus: HttpStatusCode.OK_200 21 defaultExpectedStatus: HttpStatusCode.OK_200
21 }) 22 })
22 } 23 }
@@ -34,6 +35,7 @@ export class LogsCommand extends AbstractCommand {
34 35
35 path, 36 path,
36 query: { startDate, endDate }, 37 query: { startDate, endDate },
38 implicitToken: true,
37 defaultExpectedStatus: HttpStatusCode.OK_200 39 defaultExpectedStatus: HttpStatusCode.OK_200
38 }) 40 })
39 } 41 }
diff --git a/shared/extra-utils/moderation/abuses-command.ts b/shared/extra-utils/moderation/abuses-command.ts
index 59126d0a9..03da0c85a 100644
--- a/shared/extra-utils/moderation/abuses-command.ts
+++ b/shared/extra-utils/moderation/abuses-command.ts
@@ -60,6 +60,7 @@ export class AbusesCommand extends AbstractCommand {
60 60
61 path, 61 path,
62 fields: body, 62 fields: body,
63 implicitToken: true,
63 defaultExpectedStatus: HttpStatusCode.OK_200 64 defaultExpectedStatus: HttpStatusCode.OK_200
64 })) 65 }))
65 } 66 }
@@ -106,6 +107,7 @@ export class AbusesCommand extends AbstractCommand {
106 107
107 path, 108 path,
108 query, 109 query,
110 implicitToken: true,
109 defaultExpectedStatus: HttpStatusCode.OK_200 111 defaultExpectedStatus: HttpStatusCode.OK_200
110 }) 112 })
111 } 113 }
@@ -138,6 +140,7 @@ export class AbusesCommand extends AbstractCommand {
138 140
139 path, 141 path,
140 query, 142 query,
143 implicitToken: true,
141 defaultExpectedStatus: HttpStatusCode.OK_200 144 defaultExpectedStatus: HttpStatusCode.OK_200
142 }) 145 })
143 } 146 }
@@ -154,6 +157,7 @@ export class AbusesCommand extends AbstractCommand {
154 157
155 path, 158 path,
156 fields: body, 159 fields: body,
160 implicitToken: true,
157 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 161 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
158 }) 162 })
159 } 163 }
@@ -164,7 +168,13 @@ export class AbusesCommand extends AbstractCommand {
164 const { abuseId } = options 168 const { abuseId } = options
165 const path = '/api/v1/abuses/' + abuseId 169 const path = '/api/v1/abuses/' + abuseId
166 170
167 return this.deleteRequest({ ...options, path, defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 }) 171 return this.deleteRequest({
172 ...options,
173
174 path,
175 implicitToken: true,
176 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
177 })
168 } 178 }
169 179
170 listMessages (options: OverrideCommandOptions & { 180 listMessages (options: OverrideCommandOptions & {
@@ -173,7 +183,13 @@ export class AbusesCommand extends AbstractCommand {
173 const { abuseId } = options 183 const { abuseId } = options
174 const path = '/api/v1/abuses/' + abuseId + '/messages' 184 const path = '/api/v1/abuses/' + abuseId + '/messages'
175 185
176 return this.getRequestBody<ResultList<AbuseMessage>>({ ...options, path, defaultExpectedStatus: HttpStatusCode.OK_200 }) 186 return this.getRequestBody<ResultList<AbuseMessage>>({
187 ...options,
188
189 path,
190 implicitToken: true,
191 defaultExpectedStatus: HttpStatusCode.OK_200
192 })
177 } 193 }
178 194
179 deleteMessage (options: OverrideCommandOptions & { 195 deleteMessage (options: OverrideCommandOptions & {
@@ -183,7 +199,13 @@ export class AbusesCommand extends AbstractCommand {
183 const { abuseId, messageId } = options 199 const { abuseId, messageId } = options
184 const path = '/api/v1/abuses/' + abuseId + '/messages/' + messageId 200 const path = '/api/v1/abuses/' + abuseId + '/messages/' + messageId
185 201
186 return this.deleteRequest({ ...options, path, defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 }) 202 return this.deleteRequest({
203 ...options,
204
205 path,
206 implicitToken: true,
207 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
208 })
187 } 209 }
188 210
189 addMessage (options: OverrideCommandOptions & { 211 addMessage (options: OverrideCommandOptions & {
@@ -198,6 +220,7 @@ export class AbusesCommand extends AbstractCommand {
198 220
199 path, 221 path,
200 fields: { message }, 222 fields: { message },
223 implicitToken: true,
201 defaultExpectedStatus: HttpStatusCode.OK_200 224 defaultExpectedStatus: HttpStatusCode.OK_200
202 }) 225 })
203 } 226 }
diff --git a/shared/extra-utils/overviews/overviews-command.ts b/shared/extra-utils/overviews/overviews-command.ts
index 6f56b0ce4..e15644d94 100644
--- a/shared/extra-utils/overviews/overviews-command.ts
+++ b/shared/extra-utils/overviews/overviews-command.ts
@@ -7,7 +7,7 @@ export class OverviewsCommand extends AbstractCommand {
7 getVideos (options: OverrideCommandOptions & { 7 getVideos (options: OverrideCommandOptions & {
8 page: number 8 page: number
9 }) { 9 }) {
10 const { token, page } = options 10 const { page } = options
11 const path = '/api/v1/overviews/videos' 11 const path = '/api/v1/overviews/videos'
12 12
13 const query = { page } 13 const query = { page }
@@ -15,9 +15,9 @@ export class OverviewsCommand extends AbstractCommand {
15 return this.getRequestBody<VideosOverview>({ 15 return this.getRequestBody<VideosOverview>({
16 ...options, 16 ...options,
17 17
18 token: token || null,
19 path, 18 path,
20 query, 19 query,
20 implicitToken: false,
21 defaultExpectedStatus: HttpStatusCode.OK_200 21 defaultExpectedStatus: HttpStatusCode.OK_200
22 }) 22 })
23 } 23 }
diff --git a/shared/extra-utils/search/search-command.ts b/shared/extra-utils/search/search-command.ts
index d4cfab32b..7539a21ec 100644
--- a/shared/extra-utils/search/search-command.ts
+++ b/shared/extra-utils/search/search-command.ts
@@ -25,16 +25,15 @@ export class SearchCommand extends AbstractCommand {
25 advancedChannelSearch (options: OverrideCommandOptions & { 25 advancedChannelSearch (options: OverrideCommandOptions & {
26 search: VideoChannelsSearchQuery 26 search: VideoChannelsSearchQuery
27 }) { 27 }) {
28 const { search, token } = options 28 const { search } = options
29 const path = '/api/v1/search/video-channels' 29 const path = '/api/v1/search/video-channels'
30 30
31 return this.getRequestBody<ResultList<VideoChannel>>({ 31 return this.getRequestBody<ResultList<VideoChannel>>({
32 ...options, 32 ...options,
33 33
34 token: token || null,
35
36 path, 34 path,
37 query: search, 35 query: search,
36 implicitToken: false,
38 defaultExpectedStatus: HttpStatusCode.OK_200 37 defaultExpectedStatus: HttpStatusCode.OK_200
39 }) 38 })
40 } 39 }
@@ -52,16 +51,15 @@ export class SearchCommand extends AbstractCommand {
52 advancedPlaylistSearch (options: OverrideCommandOptions & { 51 advancedPlaylistSearch (options: OverrideCommandOptions & {
53 search: VideoPlaylistsSearchQuery 52 search: VideoPlaylistsSearchQuery
54 }) { 53 }) {
55 const { search, token } = options 54 const { search } = options
56 const path = '/api/v1/search/video-playlists' 55 const path = '/api/v1/search/video-playlists'
57 56
58 return this.getRequestBody<ResultList<VideoPlaylist>>({ 57 return this.getRequestBody<ResultList<VideoPlaylist>>({
59 ...options, 58 ...options,
60 59
61 token: token || null,
62
63 path, 60 path,
64 query: search, 61 query: search,
62 implicitToken: false,
65 defaultExpectedStatus: HttpStatusCode.OK_200 63 defaultExpectedStatus: HttpStatusCode.OK_200
66 }) 64 })
67 } 65 }
@@ -85,16 +83,15 @@ export class SearchCommand extends AbstractCommand {
85 advancedVideoSearch (options: OverrideCommandOptions & { 83 advancedVideoSearch (options: OverrideCommandOptions & {
86 search: VideosSearchQuery 84 search: VideosSearchQuery
87 }) { 85 }) {
88 const { search, token } = options 86 const { search } = options
89 const path = '/api/v1/search/videos' 87 const path = '/api/v1/search/videos'
90 88
91 return this.getRequestBody<ResultList<Video>>({ 89 return this.getRequestBody<ResultList<Video>>({
92 ...options, 90 ...options,
93 91
94 token: token || null,
95
96 path, 92 path,
97 query: search, 93 query: search,
94 implicitToken: false,
98 defaultExpectedStatus: HttpStatusCode.OK_200 95 defaultExpectedStatus: HttpStatusCode.OK_200
99 }) 96 })
100 } 97 }
diff --git a/shared/extra-utils/server/config-command.ts b/shared/extra-utils/server/config-command.ts
index 959848706..f5d7fc5e3 100644
--- a/shared/extra-utils/server/config-command.ts
+++ b/shared/extra-utils/server/config-command.ts
@@ -24,8 +24,8 @@ export class ConfigCommand extends AbstractCommand {
24 return this.getRequestBody<ServerConfig>({ 24 return this.getRequestBody<ServerConfig>({
25 ...options, 25 ...options,
26 26
27 token: null,
28 path, 27 path,
28 implicitToken: false,
29 defaultExpectedStatus: HttpStatusCode.OK_200 29 defaultExpectedStatus: HttpStatusCode.OK_200
30 }) 30 })
31 } 31 }
@@ -36,8 +36,8 @@ export class ConfigCommand extends AbstractCommand {
36 return this.getRequestBody<About>({ 36 return this.getRequestBody<About>({
37 ...options, 37 ...options,
38 38
39 token: null,
40 path, 39 path,
40 implicitToken: false,
41 defaultExpectedStatus: HttpStatusCode.OK_200 41 defaultExpectedStatus: HttpStatusCode.OK_200
42 }) 42 })
43 } 43 }
@@ -49,6 +49,7 @@ export class ConfigCommand extends AbstractCommand {
49 ...options, 49 ...options,
50 50
51 path, 51 path,
52 implicitToken: true,
52 defaultExpectedStatus: HttpStatusCode.OK_200 53 defaultExpectedStatus: HttpStatusCode.OK_200
53 }) 54 })
54 } 55 }
@@ -63,6 +64,7 @@ export class ConfigCommand extends AbstractCommand {
63 64
64 path, 65 path,
65 fields: options.newCustomConfig, 66 fields: options.newCustomConfig,
67 implicitToken: true,
66 defaultExpectedStatus: HttpStatusCode.OK_200 68 defaultExpectedStatus: HttpStatusCode.OK_200
67 }) 69 })
68 } 70 }
@@ -74,6 +76,7 @@ export class ConfigCommand extends AbstractCommand {
74 ...options, 76 ...options,
75 77
76 path, 78 path,
79 implicitToken: true,
77 defaultExpectedStatus: HttpStatusCode.OK_200 80 defaultExpectedStatus: HttpStatusCode.OK_200
78 }) 81 })
79 } 82 }
diff --git a/shared/extra-utils/server/contact-form-command.ts b/shared/extra-utils/server/contact-form-command.ts
index 943e5ccbb..8d034552b 100644
--- a/shared/extra-utils/server/contact-form-command.ts
+++ b/shared/extra-utils/server/contact-form-command.ts
@@ -23,8 +23,8 @@ export class ContactFormCommand extends AbstractCommand {
23 ...options, 23 ...options,
24 24
25 path, 25 path,
26 token: null,
27 fields: body, 26 fields: body,
27 implicitToken: false,
28 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 28 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
29 }) 29 })
30 } 30 }
diff --git a/shared/extra-utils/server/debug-command.ts b/shared/extra-utils/server/debug-command.ts
index eecbb1711..8b24b3067 100644
--- a/shared/extra-utils/server/debug-command.ts
+++ b/shared/extra-utils/server/debug-command.ts
@@ -11,6 +11,7 @@ export class DebugCommand extends AbstractCommand {
11 ...options, 11 ...options,
12 12
13 path, 13 path,
14 implicitToken: true,
14 defaultExpectedStatus: HttpStatusCode.OK_200 15 defaultExpectedStatus: HttpStatusCode.OK_200
15 }) 16 })
16 } 17 }
@@ -26,6 +27,7 @@ export class DebugCommand extends AbstractCommand {
26 27
27 path, 28 path,
28 fields: body, 29 fields: body,
30 implicitToken: true,
29 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 31 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
30 }) 32 })
31 } 33 }
diff --git a/shared/extra-utils/server/follows-command.ts b/shared/extra-utils/server/follows-command.ts
index aba7bce82..4e1e56d7a 100644
--- a/shared/extra-utils/server/follows-command.ts
+++ b/shared/extra-utils/server/follows-command.ts
@@ -22,10 +22,9 @@ export class FollowsCommand extends AbstractCommand {
22 return this.getRequestBody<ResultList<ActorFollow>>({ 22 return this.getRequestBody<ResultList<ActorFollow>>({
23 ...options, 23 ...options,
24 24
25 token: null,
26
27 path, 25 path,
28 query, 26 query,
27 implicitToken: false,
29 defaultExpectedStatus: HttpStatusCode.OK_200 28 defaultExpectedStatus: HttpStatusCode.OK_200
30 }) 29 })
31 } 30 }
@@ -46,10 +45,9 @@ export class FollowsCommand extends AbstractCommand {
46 return this.getRequestBody<ResultList<ActorFollow>>({ 45 return this.getRequestBody<ResultList<ActorFollow>>({
47 ...options, 46 ...options,
48 47
49 token: null,
50
51 path, 48 path,
52 query, 49 query,
50 implicitToken: false,
53 defaultExpectedStatus: HttpStatusCode.OK_200 51 defaultExpectedStatus: HttpStatusCode.OK_200
54 }) 52 })
55 } 53 }
@@ -66,6 +64,7 @@ export class FollowsCommand extends AbstractCommand {
66 64
67 path, 65 path,
68 fields: { hosts }, 66 fields: { hosts },
67 implicitToken: true,
69 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 68 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
70 }) 69 })
71 } 70 }
@@ -79,6 +78,7 @@ export class FollowsCommand extends AbstractCommand {
79 ...options, 78 ...options,
80 79
81 path, 80 path,
81 implicitToken: true,
82 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 82 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
83 }) 83 })
84 } 84 }
@@ -92,6 +92,7 @@ export class FollowsCommand extends AbstractCommand {
92 ...options, 92 ...options,
93 93
94 path, 94 path,
95 implicitToken: true,
95 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 96 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
96 }) 97 })
97 } 98 }
@@ -105,6 +106,7 @@ export class FollowsCommand extends AbstractCommand {
105 ...options, 106 ...options,
106 107
107 path, 108 path,
109 implicitToken: true,
108 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 110 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
109 }) 111 })
110 } 112 }
@@ -118,6 +120,7 @@ export class FollowsCommand extends AbstractCommand {
118 ...options, 120 ...options,
119 121
120 path, 122 path,
123 implicitToken: true,
121 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 124 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
122 }) 125 })
123 } 126 }
diff --git a/shared/extra-utils/server/jobs-command.ts b/shared/extra-utils/server/jobs-command.ts
index 758b4a4af..392b868c1 100644
--- a/shared/extra-utils/server/jobs-command.ts
+++ b/shared/extra-utils/server/jobs-command.ts
@@ -21,6 +21,7 @@ export class JobsCommand extends AbstractCommand {
21 21
22 path, 22 path,
23 query, 23 query,
24 implicitToken: true,
24 defaultExpectedStatus: HttpStatusCode.OK_200 25 defaultExpectedStatus: HttpStatusCode.OK_200
25 }) 26 })
26 } 27 }
diff --git a/shared/extra-utils/server/plugins-command.ts b/shared/extra-utils/server/plugins-command.ts
index f06e58a22..ff49d58c4 100644
--- a/shared/extra-utils/server/plugins-command.ts
+++ b/shared/extra-utils/server/plugins-command.ts
@@ -45,6 +45,7 @@ export class PluginsCommand extends AbstractCommand {
45 pluginType, 45 pluginType,
46 uninstalled 46 uninstalled
47 }, 47 },
48 implicitToken: true,
48 defaultExpectedStatus: HttpStatusCode.OK_200 49 defaultExpectedStatus: HttpStatusCode.OK_200
49 }) 50 })
50 } 51 }
@@ -75,6 +76,7 @@ export class PluginsCommand extends AbstractCommand {
75 76
76 path, 77 path,
77 query, 78 query,
79 implicitToken: true,
78 defaultExpectedStatus: HttpStatusCode.OK_200 80 defaultExpectedStatus: HttpStatusCode.OK_200
79 }) 81 })
80 } 82 }
@@ -88,6 +90,7 @@ export class PluginsCommand extends AbstractCommand {
88 ...options, 90 ...options,
89 91
90 path, 92 path,
93 implicitToken: true,
91 defaultExpectedStatus: HttpStatusCode.OK_200 94 defaultExpectedStatus: HttpStatusCode.OK_200
92 }) 95 })
93 } 96 }
@@ -104,6 +107,7 @@ export class PluginsCommand extends AbstractCommand {
104 107
105 path, 108 path,
106 fields: { settings }, 109 fields: { settings },
110 implicitToken: true,
107 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 111 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
108 }) 112 })
109 } 113 }
@@ -117,6 +121,7 @@ export class PluginsCommand extends AbstractCommand {
117 ...options, 121 ...options,
118 122
119 path, 123 path,
124 implicitToken: true,
120 defaultExpectedStatus: HttpStatusCode.OK_200 125 defaultExpectedStatus: HttpStatusCode.OK_200
121 }) 126 })
122 } 127 }
@@ -131,6 +136,7 @@ export class PluginsCommand extends AbstractCommand {
131 ...options, 136 ...options,
132 137
133 path, 138 path,
139 implicitToken: false,
134 defaultExpectedStatus: HttpStatusCode.OK_200 140 defaultExpectedStatus: HttpStatusCode.OK_200
135 }) 141 })
136 } 142 }
@@ -145,6 +151,7 @@ export class PluginsCommand extends AbstractCommand {
145 ...options, 151 ...options,
146 152
147 path, 153 path,
154 implicitToken: false,
148 defaultExpectedStatus: HttpStatusCode.OK_200 155 defaultExpectedStatus: HttpStatusCode.OK_200
149 }) 156 })
150 } 157 }
@@ -161,6 +168,7 @@ export class PluginsCommand extends AbstractCommand {
161 168
162 path: apiPath, 169 path: apiPath,
163 fields: { npmName, path }, 170 fields: { npmName, path },
171 implicitToken: true,
164 defaultExpectedStatus: HttpStatusCode.OK_200 172 defaultExpectedStatus: HttpStatusCode.OK_200
165 }) 173 })
166 } 174 }
@@ -177,6 +185,7 @@ export class PluginsCommand extends AbstractCommand {
177 185
178 path: apiPath, 186 path: apiPath,
179 fields: { npmName, path }, 187 fields: { npmName, path },
188 implicitToken: true,
180 defaultExpectedStatus: HttpStatusCode.OK_200 189 defaultExpectedStatus: HttpStatusCode.OK_200
181 }) 190 })
182 } 191 }
@@ -192,6 +201,7 @@ export class PluginsCommand extends AbstractCommand {
192 201
193 path: apiPath, 202 path: apiPath,
194 fields: { npmName }, 203 fields: { npmName },
204 implicitToken: true,
195 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 205 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
196 }) 206 })
197 } 207 }
@@ -203,6 +213,7 @@ export class PluginsCommand extends AbstractCommand {
203 ...options, 213 ...options,
204 214
205 path, 215 path,
216 implicitToken: false,
206 defaultExpectedStatus: HttpStatusCode.OK_200 217 defaultExpectedStatus: HttpStatusCode.OK_200
207 }) 218 })
208 } 219 }
@@ -222,6 +233,7 @@ export class PluginsCommand extends AbstractCommand {
222 233
223 path, 234 path,
224 query, 235 query,
236 implicitToken: false,
225 defaultExpectedStatus: HttpStatusCode.OK_200, 237 defaultExpectedStatus: HttpStatusCode.OK_200,
226 redirects: 0 238 redirects: 0
227 }) 239 })
diff --git a/shared/extra-utils/server/redundancy-command.ts b/shared/extra-utils/server/redundancy-command.ts
index d717d35f8..728332fdd 100644
--- a/shared/extra-utils/server/redundancy-command.ts
+++ b/shared/extra-utils/server/redundancy-command.ts
@@ -16,6 +16,7 @@ export class RedundancyCommand extends AbstractCommand {
16 16
17 path, 17 path,
18 fields: { redundancyAllowed }, 18 fields: { redundancyAllowed },
19 implicitToken: true,
19 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 20 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
20 }) 21 })
21 } 22 }
@@ -42,6 +43,7 @@ export class RedundancyCommand extends AbstractCommand {
42 target 43 target
43 }, 44 },
44 45
46 implicitToken: true,
45 defaultExpectedStatus: HttpStatusCode.OK_200 47 defaultExpectedStatus: HttpStatusCode.OK_200
46 }) 48 })
47 } 49 }
@@ -57,6 +59,7 @@ export class RedundancyCommand extends AbstractCommand {
57 59
58 path, 60 path,
59 fields: { videoId }, 61 fields: { videoId },
62 implicitToken: true,
60 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 63 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
61 }) 64 })
62 } 65 }
@@ -71,6 +74,7 @@ export class RedundancyCommand extends AbstractCommand {
71 ...options, 74 ...options,
72 75
73 path, 76 path,
77 implicitToken: true,
74 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 78 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
75 }) 79 })
76 } 80 }
diff --git a/shared/extra-utils/server/stats-command.ts b/shared/extra-utils/server/stats-command.ts
index b51d9ceef..f0f02ca08 100644
--- a/shared/extra-utils/server/stats-command.ts
+++ b/shared/extra-utils/server/stats-command.ts
@@ -19,6 +19,7 @@ export class StatsCommand extends AbstractCommand {
19 19
20 path, 20 path,
21 query, 21 query,
22 implicitToken: false,
22 defaultExpectedStatus: HttpStatusCode.OK_200 23 defaultExpectedStatus: HttpStatusCode.OK_200
23 }) 24 })
24 } 25 }
diff --git a/shared/extra-utils/shared/abstract-command.ts b/shared/extra-utils/shared/abstract-command.ts
index 38129d559..1e07e9469 100644
--- a/shared/extra-utils/shared/abstract-command.ts
+++ b/shared/extra-utils/shared/abstract-command.ts
@@ -1,5 +1,13 @@
1import { HttpStatusCode } from '@shared/core-utils' 1import { HttpStatusCode } from '@shared/core-utils'
2import { makeDeleteRequest, makeGetRequest, makePostBodyRequest, makePutBodyRequest, makeUploadRequest, unwrapBody, unwrapText } from '../requests/requests' 2import {
3 makeDeleteRequest,
4 makeGetRequest,
5 makePostBodyRequest,
6 makePutBodyRequest,
7 makeUploadRequest,
8 unwrapBody,
9 unwrapText
10} from '../requests/requests'
3import { ServerInfo } from '../server/servers' 11import { ServerInfo } from '../server/servers'
4 12
5export interface OverrideCommandOptions { 13export interface OverrideCommandOptions {
@@ -7,12 +15,14 @@ export interface OverrideCommandOptions {
7 expectedStatus?: number 15 expectedStatus?: number
8} 16}
9 17
10interface CommonCommandOptions extends OverrideCommandOptions { 18interface InternalCommonCommandOptions extends OverrideCommandOptions {
11 path: string 19 path: string
20 // If we automatically send the server token if the token is not provided
21 implicitToken: boolean
12 defaultExpectedStatus: number 22 defaultExpectedStatus: number
13} 23}
14 24
15interface GetCommandOptions extends CommonCommandOptions { 25interface InternalGetCommandOptions extends InternalCommonCommandOptions {
16 query?: { [ id: string ]: any } 26 query?: { [ id: string ]: any }
17 contentType?: string 27 contentType?: string
18 accept?: string 28 accept?: string
@@ -37,15 +47,15 @@ abstract class AbstractCommand {
37 this.expectedStatus = status 47 this.expectedStatus = status
38 } 48 }
39 49
40 protected getRequestBody <T> (options: GetCommandOptions) { 50 protected getRequestBody <T> (options: InternalGetCommandOptions) {
41 return unwrapBody<T>(this.getRequest(options)) 51 return unwrapBody<T>(this.getRequest(options))
42 } 52 }
43 53
44 protected getRequestText (options: GetCommandOptions) { 54 protected getRequestText (options: InternalGetCommandOptions) {
45 return unwrapText(this.getRequest(options)) 55 return unwrapText(this.getRequest(options))
46 } 56 }
47 57
48 protected getRequest (options: GetCommandOptions) { 58 protected getRequest (options: InternalGetCommandOptions) {
49 const { redirects, query, contentType, accept } = options 59 const { redirects, query, contentType, accept } = options
50 60
51 return makeGetRequest({ 61 return makeGetRequest({
@@ -58,11 +68,11 @@ abstract class AbstractCommand {
58 }) 68 })
59 } 69 }
60 70
61 protected deleteRequest (options: CommonCommandOptions) { 71 protected deleteRequest (options: InternalCommonCommandOptions) {
62 return makeDeleteRequest(this.buildCommonRequestOptions(options)) 72 return makeDeleteRequest(this.buildCommonRequestOptions(options))
63 } 73 }
64 74
65 protected putBodyRequest (options: CommonCommandOptions & { 75 protected putBodyRequest (options: InternalCommonCommandOptions & {
66 fields?: { [ fieldName: string ]: any } 76 fields?: { [ fieldName: string ]: any }
67 }) { 77 }) {
68 const { fields } = options 78 const { fields } = options
@@ -74,7 +84,7 @@ abstract class AbstractCommand {
74 }) 84 })
75 } 85 }
76 86
77 protected postBodyRequest (options: CommonCommandOptions & { 87 protected postBodyRequest (options: InternalCommonCommandOptions & {
78 fields?: { [ fieldName: string ]: any } 88 fields?: { [ fieldName: string ]: any }
79 }) { 89 }) {
80 const { fields } = options 90 const { fields } = options
@@ -86,7 +96,7 @@ abstract class AbstractCommand {
86 }) 96 })
87 } 97 }
88 98
89 protected postUploadRequest (options: CommonCommandOptions & { 99 protected postUploadRequest (options: InternalCommonCommandOptions & {
90 fields?: { [ fieldName: string ]: any } 100 fields?: { [ fieldName: string ]: any }
91 attaches?: any 101 attaches?: any
92 }) { 102 }) {
@@ -101,7 +111,7 @@ abstract class AbstractCommand {
101 }) 111 })
102 } 112 }
103 113
104 protected putUploadRequest (options: CommonCommandOptions & { 114 protected putUploadRequest (options: InternalCommonCommandOptions & {
105 fields?: { [ fieldName: string ]: any } 115 fields?: { [ fieldName: string ]: any }
106 attaches?: any 116 attaches?: any
107 }) { 117 }) {
@@ -116,15 +126,18 @@ abstract class AbstractCommand {
116 }) 126 })
117 } 127 }
118 128
119 private buildCommonRequestOptions (options: CommonCommandOptions) { 129 private buildCommonRequestOptions (options: InternalCommonCommandOptions) {
120 const { token, expectedStatus, defaultExpectedStatus, path } = options 130 const { token, expectedStatus, defaultExpectedStatus, path } = options
121 131
132 const fallbackToken = options.implicitToken
133 ? this.server.accessToken
134 : undefined
135
122 return { 136 return {
123 url: this.server.url, 137 url: this.server.url,
124 path, 138 path,
125 139
126 // Token can be null if we don't want to add it 140 token: token !== undefined ? token : fallbackToken,
127 token: token !== undefined ? token : this.server.accessToken,
128 141
129 statusCodeExpected: expectedStatus ?? this.expectedStatus ?? defaultExpectedStatus 142 statusCodeExpected: expectedStatus ?? this.expectedStatus ?? defaultExpectedStatus
130 } 143 }
diff --git a/shared/extra-utils/users/accounts-command.ts b/shared/extra-utils/users/accounts-command.ts
index 89c080e93..4cd1d2158 100644
--- a/shared/extra-utils/users/accounts-command.ts
+++ b/shared/extra-utils/users/accounts-command.ts
@@ -17,6 +17,7 @@ export class AccountsCommand extends AbstractCommand {
17 17
18 path, 18 path,
19 query: { sort }, 19 query: { sort },
20 implicitToken: false,
20 defaultExpectedStatus: HttpStatusCode.OK_200 21 defaultExpectedStatus: HttpStatusCode.OK_200
21 }) 22 })
22 } 23 }
@@ -30,6 +31,7 @@ export class AccountsCommand extends AbstractCommand {
30 ...options, 31 ...options,
31 32
32 path, 33 path,
34 implicitToken: false,
33 defaultExpectedStatus: HttpStatusCode.OK_200 35 defaultExpectedStatus: HttpStatusCode.OK_200
34 }) 36 })
35 } 37 }
@@ -48,6 +50,7 @@ export class AccountsCommand extends AbstractCommand {
48 50
49 path, 51 path,
50 query, 52 query,
53 implicitToken: true,
51 defaultExpectedStatus: HttpStatusCode.OK_200 54 defaultExpectedStatus: HttpStatusCode.OK_200
52 }) 55 })
53 } 56 }
diff --git a/shared/extra-utils/users/blocklist-command.ts b/shared/extra-utils/users/blocklist-command.ts
index 96afdc3fd..089b5a579 100644
--- a/shared/extra-utils/users/blocklist-command.ts
+++ b/shared/extra-utils/users/blocklist-command.ts
@@ -56,6 +56,7 @@ export class BlocklistCommand extends AbstractCommand {
56 accountName: account, 56 accountName: account,
57 host: server 57 host: server
58 }, 58 },
59 implicitToken: true,
59 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 60 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
60 }) 61 })
61 } 62 }
@@ -78,6 +79,7 @@ export class BlocklistCommand extends AbstractCommand {
78 accountName: account, 79 accountName: account,
79 host: server 80 host: server
80 }, 81 },
82 implicitToken: true,
81 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 83 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
82 }) 84 })
83 } 85 }
@@ -98,6 +100,7 @@ export class BlocklistCommand extends AbstractCommand {
98 ...options, 100 ...options,
99 101
100 path, 102 path,
103 implicitToken: true,
101 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 104 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
102 }) 105 })
103 } 106 }
@@ -116,6 +119,7 @@ export class BlocklistCommand extends AbstractCommand {
116 ...options, 119 ...options,
117 120
118 path, 121 path,
122 implicitToken: true,
119 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 123 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
120 }) 124 })
121 } 125 }
@@ -128,6 +132,7 @@ export class BlocklistCommand extends AbstractCommand {
128 132
129 path, 133 path,
130 query: { start, count, sort }, 134 query: { start, count, sort },
135 implicitToken: true,
131 defaultExpectedStatus: HttpStatusCode.OK_200 136 defaultExpectedStatus: HttpStatusCode.OK_200
132 }) 137 })
133 } 138 }
diff --git a/shared/extra-utils/users/subscriptions-command.ts b/shared/extra-utils/users/subscriptions-command.ts
index 94d2af67a..e998eb426 100644
--- a/shared/extra-utils/users/subscriptions-command.ts
+++ b/shared/extra-utils/users/subscriptions-command.ts
@@ -14,6 +14,7 @@ export class SubscriptionsCommand extends AbstractCommand {
14 14
15 path, 15 path,
16 fields: { uri: options.targetUri }, 16 fields: { uri: options.targetUri },
17 implicitToken: true,
17 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 18 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
18 }) 19 })
19 } 20 }
@@ -33,6 +34,7 @@ export class SubscriptionsCommand extends AbstractCommand {
33 sort, 34 sort,
34 search 35 search
35 }, 36 },
37 implicitToken: true,
36 defaultExpectedStatus: HttpStatusCode.OK_200 38 defaultExpectedStatus: HttpStatusCode.OK_200
37 }) 39 })
38 } 40 }
@@ -48,6 +50,7 @@ export class SubscriptionsCommand extends AbstractCommand {
48 50
49 path, 51 path,
50 query: { sort }, 52 query: { sort },
53 implicitToken: true,
51 defaultExpectedStatus: HttpStatusCode.OK_200 54 defaultExpectedStatus: HttpStatusCode.OK_200
52 }) 55 })
53 } 56 }
@@ -61,6 +64,7 @@ export class SubscriptionsCommand extends AbstractCommand {
61 ...options, 64 ...options,
62 65
63 path, 66 path,
67 implicitToken: true,
64 defaultExpectedStatus: HttpStatusCode.OK_200 68 defaultExpectedStatus: HttpStatusCode.OK_200
65 }) 69 })
66 } 70 }
@@ -74,6 +78,7 @@ export class SubscriptionsCommand extends AbstractCommand {
74 ...options, 78 ...options,
75 79
76 path, 80 path,
81 implicitToken: true,
77 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 82 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
78 }) 83 })
79 } 84 }
@@ -88,6 +93,7 @@ export class SubscriptionsCommand extends AbstractCommand {
88 93
89 path, 94 path,
90 query: { 'uris[]': options.uris }, 95 query: { 'uris[]': options.uris },
96 implicitToken: true,
91 defaultExpectedStatus: HttpStatusCode.OK_200 97 defaultExpectedStatus: HttpStatusCode.OK_200
92 }) 98 })
93 } 99 }
diff --git a/shared/extra-utils/videos/live-command.ts b/shared/extra-utils/videos/live-command.ts
index e36c632ee..4f03c9127 100644
--- a/shared/extra-utils/videos/live-command.ts
+++ b/shared/extra-utils/videos/live-command.ts
@@ -23,6 +23,7 @@ export class LiveCommand extends AbstractCommand {
23 ...options, 23 ...options,
24 24
25 path: path + '/' + options.videoId, 25 path: path + '/' + options.videoId,
26 implicitToken: true,
26 defaultExpectedStatus: HttpStatusCode.OK_200 27 defaultExpectedStatus: HttpStatusCode.OK_200
27 }) 28 })
28 } 29 }
@@ -39,6 +40,7 @@ export class LiveCommand extends AbstractCommand {
39 40
40 path: path + '/' + videoId, 41 path: path + '/' + videoId,
41 fields, 42 fields,
43 implicitToken: true,
42 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 44 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
43 }) 45 })
44 } 46 }
@@ -59,6 +61,7 @@ export class LiveCommand extends AbstractCommand {
59 path, 61 path,
60 attaches, 62 attaches,
61 fields: omit(fields, 'thumbnailfile', 'previewfile'), 63 fields: omit(fields, 'thumbnailfile', 'previewfile'),
64 implicitToken: true,
62 defaultExpectedStatus: HttpStatusCode.OK_200 65 defaultExpectedStatus: HttpStatusCode.OK_200
63 })) 66 }))
64 67
diff --git a/shared/extra-utils/videos/services-command.ts b/shared/extra-utils/videos/services-command.ts
index 3b618ef66..313b7878c 100644
--- a/shared/extra-utils/videos/services-command.ts
+++ b/shared/extra-utils/videos/services-command.ts
@@ -22,6 +22,7 @@ export class ServicesCommand extends AbstractCommand {
22 22
23 path, 23 path,
24 query, 24 query,
25 implicitToken: false,
25 defaultExpectedStatus: HttpStatusCode.OK_200 26 defaultExpectedStatus: HttpStatusCode.OK_200
26 }) 27 })
27 } 28 }