diff options
author | Chocobozzz <me@florianbigard.com> | 2019-01-09 15:14:29 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-01-10 11:32:37 +0100 |
commit | a4101923e699e49ceb9ff36e971c75417fafc9f0 (patch) | |
tree | c098a87ac5a85e1bc7454facbb59ecbd6c7dac82 /shared/utils/server/contact-form.ts | |
parent | 8d00889b6038c38d9c86cbeca88a9f3c23962c48 (diff) | |
download | PeerTube-a4101923e699e49ceb9ff36e971c75417fafc9f0.tar.gz PeerTube-a4101923e699e49ceb9ff36e971c75417fafc9f0.tar.zst PeerTube-a4101923e699e49ceb9ff36e971c75417fafc9f0.zip |
Implement contact form on server side
Diffstat (limited to 'shared/utils/server/contact-form.ts')
-rw-r--r-- | shared/utils/server/contact-form.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/shared/utils/server/contact-form.ts b/shared/utils/server/contact-form.ts new file mode 100644 index 000000000..80394cf99 --- /dev/null +++ b/shared/utils/server/contact-form.ts | |||
@@ -0,0 +1,28 @@ | |||
1 | import * as request from 'supertest' | ||
2 | import { ContactForm } from '../../models/server' | ||
3 | |||
4 | function sendContactForm (options: { | ||
5 | url: string, | ||
6 | fromEmail: string, | ||
7 | fromName: string, | ||
8 | body: string, | ||
9 | expectedStatus?: number | ||
10 | }) { | ||
11 | const path = '/api/v1/server/contact' | ||
12 | |||
13 | const body: ContactForm = { | ||
14 | fromEmail: options.fromEmail, | ||
15 | fromName: options.fromName, | ||
16 | body: options.body | ||
17 | } | ||
18 | return request(options.url) | ||
19 | .post(path) | ||
20 | .send(body) | ||
21 | .expect(options.expectedStatus || 204) | ||
22 | } | ||
23 | |||
24 | // --------------------------------------------------------------------------- | ||
25 | |||
26 | export { | ||
27 | sendContactForm | ||
28 | } | ||