Delete e-mails from the Postfach; searchable assignment picker
Each Postfach e-mail gets a Delete button (POST /postfach/:id/delete), which also removes stored attachment files. The plain assignment dropdown is replaced by a searchable combobox that filters applications by company, position and city, with keyboard navigation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1341,6 +1341,23 @@ initializeDatabase().then(() => {
|
||||
}
|
||||
});
|
||||
|
||||
// Delete an e-mail from the Postfach (removes its stored attachment files too).
|
||||
app.post('/postfach/:emailId/delete', async (req, res) => {
|
||||
try {
|
||||
const emailId = req.params.emailId;
|
||||
const atts = await dbAll('SELECT pfad FROM email_anhaenge WHERE email_id = ?', [emailId]);
|
||||
for (const a of atts) {
|
||||
fs.promises.unlink(path.join(emailAnhaengeDir, a.pfad)).catch(() => {});
|
||||
}
|
||||
await dbRun('DELETE FROM email_anhaenge WHERE email_id = ?', [emailId]);
|
||||
await dbRun('DELETE FROM emails WHERE id = ?', [emailId]);
|
||||
res.redirect('/postfach?mailok=' + encodeURIComponent('E-Mail wurde gelöscht.'));
|
||||
} catch (error) {
|
||||
console.error('Error deleting e-mail:', error);
|
||||
res.redirect('/postfach?mailerror=' + encodeURIComponent('Löschen fehlgeschlagen: ' + (error.message || 'Unbekannter Fehler')));
|
||||
}
|
||||
});
|
||||
|
||||
// Count of unlinked e-mails — drives the header badge on every page.
|
||||
app.get('/api/emails/unassigned-count', async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user