mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 23:52:24 +00:00
fix(ai): accept every app language on the chat and status requests
The Coach chat, the document chat and the fenced chat declared their locale field as de/en, so a body naming French, Korean, Brazilian Portuguese or any other shipped language was refused with 422 before resolveServerLocale, which carries every locale, ever saw it. The same pair sat on the profile update, so an account could not store any other language there either, and the stored language is what the cookie-blind background work (the Coach nudge, notification texts) writes in. All four now take z.enum(locales), and the published contract for the metric, insight and biomarker status queries and the profile update lists every UI locale instead of two.
This commit is contained in:
1 parent
65fe5c34e3
commit
6f60812132
10 files changed
+197
-42
No files matched your search
@@ -24,6 +24,7 @@
|
||||
* it is always narrowed from the session.
|
||||
*/
|
||||
import { z } from "zod/v4";
|
||||
import { locales } from "@/lib/i18n/config";
|
||||
import {
|
||||
DOCUMENT_BULK_MAX_IDS,
|
||||
DOCUMENT_CONTENT_INDEX_SOURCES,
|
||||
@@ -944,14 +945,14 @@ export const DOCUMENT_CHAT_MESSAGE_MAX = 4000;
|
||||
* Request body for `POST /api/documents/inbound/{id}/chat`. No `userId` and no
|
||||
* `documentId` field — the user is narrowed from the session and the document id
|
||||
* comes from the path. `conversationId` continues an existing thread scoped to
|
||||
* this document; omitting it starts a new one. `locale` is the reply language
|
||||
* (the document chat, like the Coach, replies in de/en).
|
||||
* this document; omitting it starts a new one. `locale` is the reply language,
|
||||
* any UI locale, like the Coach's.
|
||||
*/
|
||||
export const documentChatRequestSchema = z
|
||||
.object({
|
||||
conversationId: z.string().trim().min(1).max(64).optional(),
|
||||
message: z.string().trim().min(1).max(DOCUMENT_CHAT_MESSAGE_MAX),
|
||||
locale: z.enum(["en", "de"]).optional(),
|
||||
locale: z.enum(locales).optional(),
|
||||
})
|
||||
.meta({ id: "DocumentChatRequest" });
|
||||
|
||||
@@ -990,7 +991,7 @@ export const fencedChatRequestSchema = z
|
||||
.object({
|
||||
conversationId: z.string().trim().min(1).max(64).optional(),
|
||||
message: z.string().trim().min(1).max(DOCUMENT_CHAT_MESSAGE_MAX),
|
||||
locale: z.enum(["en", "de"]).optional(),
|
||||
locale: z.enum(locales).optional(),
|
||||
attachmentIds: z
|
||||
.array(z.string().trim().min(1).max(64))
|
||||
.min(1)
|
||||
|
||||
Reference in new issue
Block a user