diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-06 15:53:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:17 +0200 |
commit | a9c58393d36d221197b48884a1960e6126ab31d7 (patch) | |
tree | b504eeefd6449d26122a7ee69affa24d242c70da /shared/extra-utils/server/contact-form-command.ts | |
parent | 2d1ad5b96063d1e430ca99128a15e2e56cb614e0 (diff) | |
download | PeerTube-a9c58393d36d221197b48884a1960e6126ab31d7.tar.gz PeerTube-a9c58393d36d221197b48884a1960e6126ab31d7.tar.zst PeerTube-a9c58393d36d221197b48884a1960e6126ab31d7.zip |
Introduce contact form command
Diffstat (limited to 'shared/extra-utils/server/contact-form-command.ts')
-rw-r--r-- | shared/extra-utils/server/contact-form-command.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/shared/extra-utils/server/contact-form-command.ts b/shared/extra-utils/server/contact-form-command.ts new file mode 100644 index 000000000..943e5ccbb --- /dev/null +++ b/shared/extra-utils/server/contact-form-command.ts | |||
@@ -0,0 +1,31 @@ | |||
1 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | ||
2 | import { ContactForm } from '../../models/server' | ||
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
4 | |||
5 | export class ContactFormCommand extends AbstractCommand { | ||
6 | |||
7 | send (options: OverrideCommandOptions & { | ||
8 | fromEmail: string | ||
9 | fromName: string | ||
10 | subject: string | ||
11 | body: string | ||
12 | }) { | ||
13 | const path = '/api/v1/server/contact' | ||
14 | |||
15 | const body: ContactForm = { | ||
16 | fromEmail: options.fromEmail, | ||
17 | fromName: options.fromName, | ||
18 | subject: options.subject, | ||
19 | body: options.body | ||
20 | } | ||
21 | |||
22 | return this.postBodyRequest({ | ||
23 | ...options, | ||
24 | |||
25 | path, | ||
26 | token: null, | ||
27 | fields: body, | ||
28 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
29 | }) | ||
30 | } | ||
31 | } | ||