# Contact Submissions Specification ## Purpose A publikus kapcsolatfelvételi végpont validálását, visszajelzéseit és a beküldött üzenetek Payload CMS-ben történő, adminisztrálható tárolását írja le. ## Requirements ### Requirement: Validate and protect contact submissions The contact endpoint SHALL accept contact submissions through `POST /api/contact` only when name, email, subject, message, and affirmative GDPR consent are present. It SHALL reject invalid email addresses, values longer than 100 characters for name, 254 for email, 200 for subject, or 5000 for message, and content matching its configured spam keywords. It SHALL trim input and remove angle brackets before persistence. #### Scenario: Submit valid contact details - **WHEN** a visitor submits all required fields, a valid email address, and consent within the configured length limits without matching spam content - **THEN** the endpoint SHALL sanitize the submitted text and continue to persistence #### Scenario: Submit invalid or disallowed contact details - **WHEN** a required field or consent is missing, the email is invalid, a field exceeds its length limit, or the content matches a configured spam keyword - **THEN** the endpoint SHALL reject the request with HTTP 400 and SHALL NOT persist the submission #### Scenario: Exceed the contact rate limit - **WHEN** a client IP submits more than three requests during a 60-second rate-limit window - **THEN** the endpoint SHALL reject the excess request with HTTP 429 ### Requirement: Persist accepted submissions The endpoint SHALL persist each accepted submission in the Payload `contact-submissions` collection with GDPR consent set to true and initial status `new`. It SHALL return success only after persistence succeeds. #### Scenario: Persist an accepted submission - **WHEN** a valid submission is accepted and Payload persistence succeeds - **THEN** the endpoint SHALL return HTTP 200 with a success message, creation timestamp, and submission identifier #### Scenario: Payload persistence fails - **WHEN** Payload cannot persist an otherwise valid submission - **THEN** the endpoint SHALL return HTTP 500 and SHALL NOT report success ### Requirement: Restrict and manage submitted records Contact submission records SHALL be available to authenticated administrators in the Payload admin. Unauthenticated API access SHALL NOT allow reading or changing those records. Administrators SHALL be able to manage the processing status using `new`, `read`, `replied`, and `archived` values. #### Scenario: Administrator reviews a submission - **WHEN** an authenticated administrator opens a stored submission in Payload - **THEN** the administrator SHALL be able to review its contact fields and update its processing status #### Scenario: Unauthenticated user attempts to access stored submissions - **WHEN** a request without an authenticated user attempts to read or modify a submission through the Payload API - **THEN** Payload SHALL deny the operation ### Requirement: Reject unsupported contact methods The contact endpoint SHALL reject methods other than `POST` with HTTP 405. #### Scenario: Submit using an unsupported method - **WHEN** a client calls the contact endpoint using `GET`, `PUT`, or `DELETE` - **THEN** the endpoint SHALL return HTTP 405