- Updated .env.example to include configuration for OnlyOffice Document Server. - Modified the workspace configuration to remove the drive-suite path. - Adjusted TypeScript environment imports for consistency. - Enhanced Next.js configuration to disable canvas in Webpack. - Updated package.json to include new dependencies for OnlyOffice and PDF.js. - Added global styles for OnlyOffice theme integration in the CSS. - Created new layout and page components for the Drive feature, including public sharing and editing functionalities. - Updated metadata handling across various layouts to reflect the new app structure.
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
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
|
|
drive_path?: string
|
|
}
|
|
|
|
export function mapApiAttachmentsToEmail(
|
|
list: ApiMessageAttachment[] | undefined
|
|
): EmailAttachment[] {
|
|
if (!list?.length) return []
|
|
return list
|
|
.filter((a) => !a.is_inline)
|
|
.map((a) => ({
|
|
id: a.id,
|
|
name: a.filename || "Pièce jointe",
|
|
kind: resolveAttachmentKind(a.filename, kindFromContentType(a.content_type)),
|
|
contentType: a.content_type || undefined,
|
|
drivePath: a.drive_path || undefined,
|
|
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
|
|
}
|