aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils')
-rw-r--r--shared/extra-utils/custom-pages/custom-pages.ts31
-rw-r--r--shared/extra-utils/index.ts18
-rw-r--r--shared/extra-utils/requests/requests.ts2
-rw-r--r--shared/extra-utils/server/config.ts3
-rw-r--r--shared/extra-utils/server/plugins.ts4
-rw-r--r--shared/extra-utils/server/servers.ts3
6 files changed, 57 insertions, 4 deletions
diff --git a/shared/extra-utils/custom-pages/custom-pages.ts b/shared/extra-utils/custom-pages/custom-pages.ts
new file mode 100644
index 000000000..bf2d16c70
--- /dev/null
+++ b/shared/extra-utils/custom-pages/custom-pages.ts
@@ -0,0 +1,31 @@
1import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
2import { makeGetRequest, makePutBodyRequest } from '../requests/requests'
3
4function getInstanceHomepage (url: string, statusCodeExpected = HttpStatusCode.OK_200) {
5 const path = '/api/v1/custom-pages/homepage/instance'
6
7 return makeGetRequest({
8 url,
9 path,
10 statusCodeExpected
11 })
12}
13
14function updateInstanceHomepage (url: string, token: string, content: string) {
15 const path = '/api/v1/custom-pages/homepage/instance'
16
17 return makePutBodyRequest({
18 url,
19 path,
20 token,
21 fields: { content },
22 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
23 })
24}
25
26// ---------------------------------------------------------------------------
27
28export {
29 getInstanceHomepage,
30 updateInstanceHomepage
31}
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts
index 898a92d43..3bc09ead5 100644
--- a/shared/extra-utils/index.ts
+++ b/shared/extra-utils/index.ts
@@ -1,15 +1,26 @@
1export * from './bulk/bulk' 1export * from './bulk/bulk'
2
2export * from './cli/cli' 3export * from './cli/cli'
4
5export * from './custom-pages/custom-pages'
6
3export * from './feeds/feeds' 7export * from './feeds/feeds'
8
4export * from './mock-servers/mock-instances-index' 9export * from './mock-servers/mock-instances-index'
5export * from './miscs/miscs' 10
11export * from './miscs/email'
6export * from './miscs/sql' 12export * from './miscs/sql'
13export * from './miscs/miscs'
7export * from './miscs/stubs' 14export * from './miscs/stubs'
15
8export * from './moderation/abuses' 16export * from './moderation/abuses'
9export * from './plugins/mock-blocklist' 17export * from './plugins/mock-blocklist'
18
10export * from './requests/check-api-params' 19export * from './requests/check-api-params'
11export * from './requests/requests' 20export * from './requests/requests'
21
12export * from './search/videos' 22export * from './search/videos'
23
13export * from './server/activitypub' 24export * from './server/activitypub'
14export * from './server/clients' 25export * from './server/clients'
15export * from './server/config' 26export * from './server/config'
@@ -18,9 +29,14 @@ export * from './server/follows'
18export * from './server/jobs' 29export * from './server/jobs'
19export * from './server/plugins' 30export * from './server/plugins'
20export * from './server/servers' 31export * from './server/servers'
32
21export * from './users/accounts' 33export * from './users/accounts'
34export * from './users/blocklist'
22export * from './users/login' 35export * from './users/login'
36export * from './users/user-notifications'
37export * from './users/user-subscriptions'
23export * from './users/users' 38export * from './users/users'
39
24export * from './videos/live' 40export * from './videos/live'
25export * from './videos/services' 41export * from './videos/services'
26export * from './videos/video-blacklist' 42export * from './videos/video-blacklist'
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts
index 8b5cddf4a..38e24d897 100644
--- a/shared/extra-utils/requests/requests.ts
+++ b/shared/extra-utils/requests/requests.ts
@@ -26,6 +26,7 @@ function makeGetRequest (options: {
26 contentType?: string 26 contentType?: string
27 range?: string 27 range?: string
28 redirects?: number 28 redirects?: number
29 accept?: string
29}) { 30}) {
30 if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400 31 if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400
31 if (options.contentType === undefined) options.contentType = 'application/json' 32 if (options.contentType === undefined) options.contentType = 'application/json'
@@ -36,6 +37,7 @@ function makeGetRequest (options: {
36 if (options.token) req.set('Authorization', 'Bearer ' + options.token) 37 if (options.token) req.set('Authorization', 'Bearer ' + options.token)
37 if (options.query) req.query(options.query) 38 if (options.query) req.query(options.query)
38 if (options.range) req.set('Range', options.range) 39 if (options.range) req.set('Range', options.range)
40 if (options.accept) req.set('Accept', options.accept)
39 if (options.redirects) req.redirects(options.redirects) 41 if (options.redirects) req.redirects(options.redirects)
40 42
41 return req.expect(options.statusCodeExpected) 43 return req.expect(options.statusCodeExpected)
diff --git a/shared/extra-utils/server/config.ts b/shared/extra-utils/server/config.ts
index b70110852..9fcfb31fd 100644
--- a/shared/extra-utils/server/config.ts
+++ b/shared/extra-utils/server/config.ts
@@ -98,7 +98,8 @@ function updateCustomSubConfig (url: string, token: string, newConfig: DeepParti
98 signup: { 98 signup: {
99 enabled: false, 99 enabled: false,
100 limit: 5, 100 limit: 5,
101 requiresEmailVerification: false 101 requiresEmailVerification: false,
102 minimumAge: 16
102 }, 103 },
103 admin: { 104 admin: {
104 email: 'superadmin1@example.com' 105 email: 'superadmin1@example.com'
diff --git a/shared/extra-utils/server/plugins.ts b/shared/extra-utils/server/plugins.ts
index 864954ee7..d53e5b382 100644
--- a/shared/extra-utils/server/plugins.ts
+++ b/shared/extra-utils/server/plugins.ts
@@ -4,12 +4,12 @@ import { expect } from 'chai'
4import { readJSON, writeJSON } from 'fs-extra' 4import { readJSON, writeJSON } from 'fs-extra'
5import { join } from 'path' 5import { join } from 'path'
6import { RegisteredServerSettings } from '@shared/models' 6import { RegisteredServerSettings } from '@shared/models'
7import { PeertubePluginIndexList } from '../../models/plugins/peertube-plugin-index-list.model' 7import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
8import { PeertubePluginIndexList } from '../../models/plugins/plugin-index/peertube-plugin-index-list.model'
8import { PluginType } from '../../models/plugins/plugin.type' 9import { PluginType } from '../../models/plugins/plugin.type'
9import { buildServerDirectory, root } from '../miscs/miscs' 10import { buildServerDirectory, root } from '../miscs/miscs'
10import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' 11import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
11import { ServerInfo } from './servers' 12import { ServerInfo } from './servers'
12import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
13 13
14function listPlugins (parameters: { 14function listPlugins (parameters: {
15 url: string 15 url: string
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts
index 479f08e12..d04757470 100644
--- a/shared/extra-utils/server/servers.ts
+++ b/shared/extra-utils/server/servers.ts
@@ -45,9 +45,12 @@ interface ServerInfo {
45 uuid: string 45 uuid: string
46 name?: string 46 name?: string
47 url?: string 47 url?: string
48
48 account?: { 49 account?: {
49 name: string 50 name: string
50 } 51 }
52
53 embedPath?: string
51 } 54 }
52 55
53 remoteVideo?: { 56 remoteVideo?: {