- 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.
34 lines
910 B
TypeScript
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
|
|
}
|