ultisuite-client/lib/api/map-message-attachments.ts
R3D347HR4Y 8a02c10ba3 Add environment configuration and update email view components
- Created a .cursorignore file to manage local environment files.
- Updated .env.example to reflect changes in the public app URL.
- Modified the gmail workspace configuration to include the drive-suite path.
- Enhanced email view components to support attachment handling and fallback for plain text bodies.
- Improved user experience by updating attachment display logic and integrating inline attachment support.
2026-06-04 00:12:43 +02:00

34 lines
910 B
TypeScript

import type { EmailAttachment } from "@/lib/email-data"
import { resolveAttachmentKind } from "@/lib/attachment-display"
export interface ApiMessageAttachment {
id: string
filename: string
content_type: string
size: number
is_inline?: boolean
content_id?: string
}
export function mapApiAttachmentsToEmail(
list: ApiMessageAttachment[] | undefined
): EmailAttachment[] {
if (!list?.length) return []
return list
.filter((a) => !a.is_inline)
.map((a) => ({
name: a.filename || "Pièce jointe",
kind: resolveAttachmentKind(a.filename, kindFromContentType(a.content_type)),
sizeBytes: a.size > 0 ? a.size : undefined,
}))
}
function kindFromContentType(
contentType: string
): EmailAttachment["kind"] | undefined {
const ct = contentType.toLowerCase()
if (ct.includes("pdf")) return "pdf"
if (ct.startsWith("image/")) return "image"
return undefined
}