- Search box in the header filters the current folder's list (sender/subject),
client-side; works across the merged Archived/Deleted views too.
- Archive and Delete are now implemented as soft moves: migration 157 adds
mailbox_state ('active'|'archived'|'deleted') to email_queue + received_emails.
Archive → 'archived', Delete → 'deleted' (trash). Restore → 'active'. Deleting
FROM the Deleted folder is permanent (hard row delete).
- New cross-account system folders Archived + Deleted (merge sent + received of
that state, sorted by date). Normal folders now exclude archived/deleted.
- Backend: /queue + /received gain a `state` filter (default active + legacy
NULL); new POST /item/:kind/:id/state (archive/delete/restore) and DELETE
/item/:kind/:id (purge, email.edit).
- Toolbar Archive/Delete wired; Restore + "Delete permanently" shown in the
system folders.
Frontend build + migration boot (157) verified.
34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
/**
|
|
* Messages — Archive / Delete (trash) support.
|
|
*
|
|
* `mailbox_state` on both mail tables: 'active' (normal folders), 'archived'
|
|
* (Archived folder), or 'deleted' (Deleted/trash folder). Delete is soft — the
|
|
* row moves to 'deleted' and is only removed for good when purged FROM the
|
|
* Deleted folder. Legacy rows have NULL, treated as 'active'. Additive/guarded.
|
|
*/
|
|
exports.up = async function up(knex) {
|
|
for (const table of ['email_queue', 'received_emails']) {
|
|
// eslint-disable-next-line no-await-in-loop
|
|
const has = await knex.schema.hasColumn(table, 'mailbox_state');
|
|
// eslint-disable-next-line no-await-in-loop
|
|
if (!has) {
|
|
// eslint-disable-next-line no-await-in-loop
|
|
await knex.schema.alterTable(table, (t) => {
|
|
t.string('mailbox_state', 16).defaultTo('active');
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
exports.down = async function down(knex) {
|
|
for (const table of ['email_queue', 'received_emails']) {
|
|
// eslint-disable-next-line no-await-in-loop
|
|
const has = await knex.schema.hasColumn(table, 'mailbox_state');
|
|
// eslint-disable-next-line no-await-in-loop
|
|
if (has) {
|
|
// eslint-disable-next-line no-await-in-loop
|
|
await knex.schema.alterTable(table, (t) => { t.dropColumn('mailbox_state'); });
|
|
}
|
|
}
|
|
};
|