mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-04 08:15:41 +00:00
api.email.getAttachmentText reads PDF (pdf.js), Word, Excel, PowerPoint and OpenDocument files (own reader over fflate and DOMParser, unpacking capped at 50 MB), text, CSV, HTML, calendar and address files, and answers with a status for what it can't read. The extraction lives in lib/attachment-text so Files can use it too. The sandbox runtime now copies every flag the host sends into api.host.features; before, it kept only the three core flags, so the assistant's flags never reached a plugin. The host bridge assertions in plugin-host-features.test.ts compare against the core flags plus the assistant's (withAssistant), since the init payload and host-change now carry attachmentText too.
23 lines
948 B
TypeScript
23 lines
948 B
TypeScript
// Area b of the assistant's host APIs, inside the plugin sandbox (see README.md).
|
|
|
|
import type { CallApi, RuntimeAdditions } from './runtime';
|
|
import type { AttachmentTextOptions, AttachmentTextView } from './b.types';
|
|
|
|
/** Reads that download and unpack a file get the network timeout. */
|
|
const READ_TIMEOUT_MS = 120_000;
|
|
|
|
/** The methods this area adds to the plugin's api, by namespace. */
|
|
export function runtime(callApi: CallApi): RuntimeAdditions {
|
|
return {
|
|
email: {
|
|
/**
|
|
* The text of one attachment of a message (email:blob-read, 30 a
|
|
* minute): PDF, Word, Excel, PowerPoint, OpenDocument, text, CSV,
|
|
* HTML, calendar and address files. See AttachmentTextView.status.
|
|
*/
|
|
getAttachmentText: (emailId: string, blobId: string, options?: AttachmentTextOptions) =>
|
|
callApi('email.getAttachmentText', [emailId, blobId, options], READ_TIMEOUT_MS) as Promise<AttachmentTextView>,
|
|
},
|
|
};
|
|
}
|