aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/server-commands/src/server/contact-form-command.ts
blob: 399e06d2fd6c6cf375573eca3f768e2ec0e0ca44 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { ContactForm, HttpStatusCode } from '@peertube/peertube-models'
import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js'

export class ContactFormCommand extends AbstractCommand {

  send (options: OverrideCommandOptions & {
    fromEmail: string
    fromName: string
    subject: string
    body: string
  }) {
    const path = '/api/v1/server/contact'

    const body: ContactForm = {
      fromEmail: options.fromEmail,
      fromName: options.fromName,
      subject: options.subject,
      body: options.body
    }

    return this.postBodyRequest({
      ...options,

      path,
      fields: body,
      implicitToken: false,
      defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
    })
  }
}