feat: setup the attachment to the passenger api

This commit is contained in:
Nathnael
2026-07-18 09:44:14 +00:00
parent 4f043ea4bf
commit bdcd5e957e
12 changed files with 781 additions and 116 deletions

View File

@@ -916,10 +916,37 @@ model SupportMessage {
id String @id @default(uuid())
conversationId String
sender SupportSender
text String
attachments Json?
/// NULL for an attachment-only message — absence of text is representable
/// rather than smuggled through "". The DTO maps NULL -> "".
text String?
createdAt DateTime @default(now())
conversation SupportConversation @relation(fields: [conversationId], references: [id])
attachments SupportAttachment[]
/// Backs keyset pagination of a thread (newest-first over (createdAt, id)).
/// Without it, paging a long thread degrades to a scan per page.
@@index([conversationId, createdAt])
@@schema("passenger")
}
/// A file posted on a support message.
///
/// The freight side stores the equivalent in its polymorphic `freight.files`
/// table; this app has no such table (and no TypeORM), so chat attachments get a
/// purpose-built model rather than a shared one. Bytes live in MinIO — `url` is
/// the unsigned object path, signed on read for preview.
model SupportAttachment {
id String @id @default(uuid())
messageId String
name String
mimeType String
/// Bytes.
size Int
/// Unsigned MinIO object URL. Not directly fetchable by a browser — the API
/// mints a short-lived signed URL per response.
url String
createdAt DateTime @default(now())
message SupportMessage @relation(fields: [messageId], references: [id], onDelete: Cascade)
@@index([messageId])
@@schema("passenger")
}