aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/custom-pages/custom-pages.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-06 09:55:05 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:16 +0200
commite8bd7ce7ccafe3e064b03978e9b512c1a4cc99e6 (patch)
treec888e13aca3fc239f46d44045df6bf8e2a2ef0d3 /shared/extra-utils/custom-pages/custom-pages.ts
parent329619b3453479f76c049816b7403b86e9d45cb5 (diff)
downloadPeerTube-e8bd7ce7ccafe3e064b03978e9b512c1a4cc99e6.tar.gz
PeerTube-e8bd7ce7ccafe3e064b03978e9b512c1a4cc99e6.tar.zst
PeerTube-e8bd7ce7ccafe3e064b03978e9b512c1a4cc99e6.zip
Introduce CustomPage command
Diffstat (limited to 'shared/extra-utils/custom-pages/custom-pages.ts')
-rw-r--r--shared/extra-utils/custom-pages/custom-pages.ts47
1 files changed, 23 insertions, 24 deletions
diff --git a/shared/extra-utils/custom-pages/custom-pages.ts b/shared/extra-utils/custom-pages/custom-pages.ts
index bf2d16c70..56dabdc0f 100644
--- a/shared/extra-utils/custom-pages/custom-pages.ts
+++ b/shared/extra-utils/custom-pages/custom-pages.ts
@@ -1,31 +1,30 @@
1import { CustomPage } from '@shared/models'
1import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
2import { makeGetRequest, makePutBodyRequest } from '../requests/requests' 3import { AbstractCommand, OverrideCommandOptions } from '../shared'
3 4
4function getInstanceHomepage (url: string, statusCodeExpected = HttpStatusCode.OK_200) { 5export class CustomPagesCommand extends AbstractCommand {
5 const path = '/api/v1/custom-pages/homepage/instance'
6 6
7 return makeGetRequest({ 7 getInstanceHomepage (options: OverrideCommandOptions = {}) {
8 url, 8 const path = '/api/v1/custom-pages/homepage/instance'
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 9
17 return makePutBodyRequest({ 10 return this.getRequestBody<CustomPage>({
18 url, 11 ...options,
19 path, 12 path,
20 token, 13 defaultExpectedStatus: HttpStatusCode.OK_200
21 fields: { content }, 14 })
22 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 15 }
23 })
24}
25 16
26// --------------------------------------------------------------------------- 17 updateInstanceHomepage (options: OverrideCommandOptions & {
18 content: string
19 }) {
20 const { content } = options
21 const path = '/api/v1/custom-pages/homepage/instance'
27 22
28export { 23 return this.putBodyRequest({
29 getInstanceHomepage, 24 ...options,
30 updateInstanceHomepage 25 path,
26 fields: { content },
27 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
28 })
29 }
31} 30}