|
private shallMessageBeArchived(messageHeader: MessageHeader, settings: AccountSettings): boolean { |
|
//determine ageInDays |
|
let ageInDays: number = 0; |
|
let other: boolean = true; |
|
|
|
//unread |
|
if (!messageHeader.read) { |
|
if (!settings.bArchiveUnread) { |
|
//message unread, but unread messages shall not be archived |
|
return false; |
|
} |
|
|
|
other = false; |
|
ageInDays = Math.max(ageInDays, settings.daysUnread); |
|
} |
|
|
|
//marked (starred) |
|
if (messageHeader.flagged) { |
|
if (!settings.bArchiveMarked) { |
|
//message flagged, but flagged messages shall not be archived |
|
return false; |
|
} |
|
|
|
other = false; |
|
ageInDays = Math.max(ageInDays, settings.daysMarked); |
|
} |
|
|
|
//tagged |
|
|
|
//GMail uses the tag "junk" to mark junk mails, but they shall not be classified as normal "tags" |
|
const tags = messageHeader.tags.filter((tag) => tag !== "junk" && tag !== "nonjunk"); |
|
|
|
if (tags.length > 0) { |
|
if (!settings.bArchiveTagged) { |
|
//message tagged, but tagged messages shall not be archived |
|
return false; |
|
} |
|
|
|
other = false; |
|
ageInDays = Math.max(ageInDays, settings.daysTagged); |
|
} |
|
|
|
if (other) { |
|
if (!settings.bArchiveOther) { |
|
//other message, but other messages shall not be archived |
|
return false; |
|
} |
|
ageInDays = Math.max(ageInDays, settings.daysOther); |
|
} |
|
|
|
const minDate: Date = new Date(Date.now() - ageInDays * 24 * 60 * 60 * 1000); |
|
if (messageHeader.date > minDate) { |
|
return false; |
|
} |
|
|
|
//TODO: How do we know, that archiving is possible at all? |
|
//look into the first message of a folder and give it to a webapi experiment? |
|
//(right now simply nothing happens when you archive in such an account) |
|
|
|
/* |
|
//check if archive is possible for this message/in this account |
|
//TODO: actual it is not clear how to get the archiveEnabled for the identity in the beginning and not for every message |
|
const mail3PaneWindow: Mail3Pane = Helper.getMail3Pane(); |
|
if (mail3PaneWindow.getIdentityForHeader(dbHdr).archiveEnabled) |
|
{ |
|
this.messages.push(dbHdr); |
|
} |
|
*/ |
|
return true; |
|
} |
Hi, my use-pattern is starring messages I'd like to keep (without necessarily reading them), but having auto-archive active for all other messages. Reading through
Archiver::shallMessageBeArchivedit feels like this use-case isn't supported (all unread messages get archived if their expiration time has reached, regardless of starred status).AutoarchiveReloaded/src/backgroundScript/Archiver.ts
Lines 202 to 271 in 0fdd084
I'm wondering if that's a use case the extension aims to support.
Thanks !