Files
API/src/models/feedback/public/submission.interface.ts
T
PaddyandClaude Opus 5.5 f3f4ca2c9f
Test and deploy / test-and-deploy (pull_request) Successful in 46s
Answer a retried feedback submission with the one already saved
When a submission saved but its response never reached the phone, the
form showed an error, the visitor tapped "Feedback absenden" again, and a
second identical row was stored (seen twice in production: 82/83, 87/88).

The form now sends a clientToken, one UUID per visit, on every attempt.
A token that is already stored returns the original submissionId and
saves nothing; the lookup runs before the eligibility check, so a retry
still succeeds if the feedback window closed in between. Two concurrent
retries are settled by a UNIQUE index on submissions.client_token: the
loser gets ER_DUP_ENTRY, rolls back and returns the winner's id. A missing
or non-UUID token behaves as before, so cached copies of the old form
still submit.

Migration 003 must be applied before this is deployed - the INSERT now
writes client_token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 17:48:33 +01:00

104 lines
2.8 KiB
TypeScript

/**
* @swagger
* components:
* schemas:
* SubmissionRequest:
* type: object
* properties:
* answers:
* type: array
* items:
* type: object
* properties:
* eventQuestionId:
* type: integer
* example: 12
* songId:
* type: integer
* nullable: true
* description: SONG_PICK only
* ratings:
* type: array
* description: SONG_RATING only
* items:
* type: object
* properties:
* songId:
* type: integer
* rating:
* type: integer
* minimum: 1
* maximum: 5
* text:
* type: string
* nullable: true
* description: FREE_TEXT only
* guestBook:
* type: object
* nullable: true
* properties:
* displayName:
* type: string
* nullable: true
* message:
* type: string
* nullable: true
* newsletter:
* type: object
* nullable: true
* properties:
* firstName:
* type: string
* lastName:
* type: string
* email:
* type: string
* website:
* type: string
* description: Honeypot field. Must stay empty; a real visitor never fills it in.
* clientToken:
* type: string
* format: uuid
* description: Generated once per form and resent on every retry. A retry whose token is already stored returns the original submissionId instead of saving a duplicate. Optional; a value that isn't a UUID is ignored.
* SubmissionResponse:
* type: object
* properties:
* submissionId:
* type: integer
* example: 91
* newsletterDropped:
* type: boolean
* description: True if the newsletter opt-in was present but failed validation (e.g. a malformed email) - the rest of the submission still saved.
*/
export interface RatingInput {
songId: number;
rating: number;
}
export interface AnswerInput {
eventQuestionId: number;
songId?: number;
ratings?: RatingInput[];
text?: string;
}
export interface GuestBookInput {
displayName?: string;
message?: string;
}
export interface NewsletterInput {
firstName: string;
lastName: string;
email: string;
}
export interface SubmissionRequestBody {
answers?: AnswerInput[];
guestBook?: GuestBookInput;
newsletter?: NewsletterInput;
website?: string;
clientToken?: string;
}