]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/extra-utils/server/contact-form.ts
Merge branch 'release/3.1.0' into develop
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / server / contact-form.ts
1 import * as request from 'supertest'
2 import { ContactForm } from '../../models/server'
3 import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
4
5 function sendContactForm (options: {
6 url: string
7 fromEmail: string
8 fromName: string
9 subject: string
10 body: string
11 expectedStatus?: number
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 return request(options.url)
22 .post(path)
23 .send(body)
24 .expect(options.expectedStatus || HttpStatusCode.NO_CONTENT_204)
25 }
26
27 // ---------------------------------------------------------------------------
28
29 export {
30 sendContactForm
31 }