diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-15 15:26:15 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-24 16:25:52 +0200 |
commit | 94565d52bb2883e09f16d1363170ac9c0dccb7a1 (patch) | |
tree | 3dcd20cd7b5a5cca80bce32b655cdbfaddf7aa59 /shared/extra-utils/server/contact-form.ts | |
parent | 4ee7a4c9ac9280cda930a281c2d5a9a4c409cc14 (diff) | |
download | PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.tar.gz PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.tar.zst PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.zip |
Shared utils -> extra-utils
Because they need dev dependencies
Diffstat (limited to 'shared/extra-utils/server/contact-form.ts')
-rw-r--r-- | shared/extra-utils/server/contact-form.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/shared/extra-utils/server/contact-form.ts b/shared/extra-utils/server/contact-form.ts new file mode 100644 index 000000000..80394cf99 --- /dev/null +++ b/shared/extra-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 | } | ||