diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
commit | a24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch) | |
tree | a54b0f6c921ba83a6e909cd0ced325b2d4b8863c /shared/extra-utils/custom-pages | |
parent | 5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff) | |
parent | c63830f15403ac4e750829f27d8bbbdc9a59282c (diff) | |
download | PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip |
Merge branch 'next' into develop
Diffstat (limited to 'shared/extra-utils/custom-pages')
-rw-r--r-- | shared/extra-utils/custom-pages/custom-pages-command.ts | 33 | ||||
-rw-r--r-- | shared/extra-utils/custom-pages/custom-pages.ts | 31 | ||||
-rw-r--r-- | shared/extra-utils/custom-pages/index.ts | 1 |
3 files changed, 34 insertions, 31 deletions
diff --git a/shared/extra-utils/custom-pages/custom-pages-command.ts b/shared/extra-utils/custom-pages/custom-pages-command.ts new file mode 100644 index 000000000..cd869a8de --- /dev/null +++ b/shared/extra-utils/custom-pages/custom-pages-command.ts | |||
@@ -0,0 +1,33 @@ | |||
1 | import { CustomPage, HttpStatusCode } from '@shared/models' | ||
2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
3 | |||
4 | export class CustomPagesCommand extends AbstractCommand { | ||
5 | |||
6 | getInstanceHomepage (options: OverrideCommandOptions = {}) { | ||
7 | const path = '/api/v1/custom-pages/homepage/instance' | ||
8 | |||
9 | return this.getRequestBody<CustomPage>({ | ||
10 | ...options, | ||
11 | |||
12 | path, | ||
13 | implicitToken: false, | ||
14 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
15 | }) | ||
16 | } | ||
17 | |||
18 | updateInstanceHomepage (options: OverrideCommandOptions & { | ||
19 | content: string | ||
20 | }) { | ||
21 | const { content } = options | ||
22 | const path = '/api/v1/custom-pages/homepage/instance' | ||
23 | |||
24 | return this.putBodyRequest({ | ||
25 | ...options, | ||
26 | |||
27 | path, | ||
28 | fields: { content }, | ||
29 | implicitToken: true, | ||
30 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
31 | }) | ||
32 | } | ||
33 | } | ||
diff --git a/shared/extra-utils/custom-pages/custom-pages.ts b/shared/extra-utils/custom-pages/custom-pages.ts deleted file mode 100644 index bf2d16c70..000000000 --- a/shared/extra-utils/custom-pages/custom-pages.ts +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
2 | import { makeGetRequest, makePutBodyRequest } from '../requests/requests' | ||
3 | |||
4 | function 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 | |||
14 | function 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 | |||
28 | export { | ||
29 | getInstanceHomepage, | ||
30 | updateInstanceHomepage | ||
31 | } | ||
diff --git a/shared/extra-utils/custom-pages/index.ts b/shared/extra-utils/custom-pages/index.ts new file mode 100644 index 000000000..58aed04f2 --- /dev/null +++ b/shared/extra-utils/custom-pages/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './custom-pages-command' | |||