feat: implement multi-segment PDF email attachments and add PWA mobile icons
Build and Push Multi-Platform Images / build-and-push (push) Successful in 33s
Build and Push Multi-Platform Images / build-and-push (push) Successful in 33s
This commit is contained in:
@@ -200,7 +200,7 @@ export class InboxController {
|
||||
subject: string;
|
||||
body: string;
|
||||
html?: string;
|
||||
filename?: string;
|
||||
segments: { pages: number[]; filename: string }[];
|
||||
},
|
||||
@Request() req: any,
|
||||
): Promise<void> {
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
type InboxSource,
|
||||
} from '../database/entities/inbox-document.entity';
|
||||
import { MailService } from '../postprocessing/mail.service';
|
||||
import { applyEditsToTemp, cleanupTemp, buildSegmentBuffer } from '../inbox-postprocessor/edit-applier';
|
||||
import { buildSegmentBuffer } from '../inbox-postprocessor/edit-applier';
|
||||
|
||||
export interface InboxFile {
|
||||
id: string;
|
||||
@@ -273,24 +273,27 @@ export class InboxService {
|
||||
subject: string;
|
||||
body: string;
|
||||
html?: string;
|
||||
filename?: string;
|
||||
segments: { pages: number[]; filename: string }[];
|
||||
},
|
||||
): Promise<void> {
|
||||
const { doc, pdfPath } = await this.resolveDocument(id, preferredUsername);
|
||||
let tmpPath: string | null = null;
|
||||
try {
|
||||
tmpPath = await applyEditsToTemp(doc, pdfPath);
|
||||
const content = await fs.readFile(tmpPath);
|
||||
const filename = opts.filename ? `${opts.filename}.pdf` : doc.OriginalName;
|
||||
await this.mailService.sendMail({
|
||||
to: opts.to,
|
||||
subject: opts.subject,
|
||||
body: opts.body,
|
||||
html: opts.html,
|
||||
attachments: [{ filename, content }],
|
||||
});
|
||||
} finally {
|
||||
await cleanupTemp(tmpPath);
|
||||
}
|
||||
const deleted = new Set(doc.DeletedPages ?? []);
|
||||
|
||||
const attachments = await Promise.all(
|
||||
opts.segments.map(async (seg) => {
|
||||
const safePages = seg.pages.filter((p) => p >= 1 && p <= doc.PageCount && !deleted.has(p));
|
||||
const content = await buildSegmentBuffer(doc, pdfPath, safePages);
|
||||
const filename = seg.filename.endsWith('.pdf') ? seg.filename : `${seg.filename}.pdf`;
|
||||
return { filename, content };
|
||||
}),
|
||||
);
|
||||
|
||||
await this.mailService.sendMail({
|
||||
to: opts.to,
|
||||
subject: opts.subject,
|
||||
body: opts.body,
|
||||
html: opts.html,
|
||||
attachments,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user