Open NextTherapist opened 2 years ago
No, not at the moment. also it cannot create new folders; that one might be tricky as it is hard to do in synchronous manner (move mail to a folder that doesn't exist, so create the folder first, then move it to the new folder) - something I have achieved in my QuickFolders Add-on in the quickMove method.
I am also interested by this feature.
I suggest to offer a hierarchical automatic sorting of mails based on the SENDER with automatic folder creation functionality.
Level 1 = Extension (com / net / org / ...) Level 2 = Domain Level 3 = Subdomain Level 4 = User Level 5 = Displayed name
The user would have the possibility to select the precited value for each level. By default each level would has the value "Not used". by this way, if the user select only Level 1 = Extension, all mails will be sorted in folders as COM NET ORG ...
If the user select Level 1 = Extension + Level 2 = Domain, all mailswill be sorted in folders as COM Domain A Domain B Domain C NET Domain A Domain B Domain C ....
With an option "In case of absence of value on one or all selected options, move the mails in folder ... (selection button)"
I came to Issues today to look to see if this exact challenge was already reported, so ... ➕1
My application : I get lots of emails every day from websites that I own. Most of them have Subjects like:
Your site has been upgraded: https:\/\/domain.tld Alert: https:\/\/sub.domain.tld appears to be down
I've been using Sieve over Dovecot with Regex to parse the domain names and use them to create folders ( fileinto :create %fullPathWithDomain
). My folders look like this:
But I'm moving to Exim which has limited Sieve filtering, and Exim filters aren't designed for this. So I want to do this on the client now (Tb).
Rather than using standard filters with RegEx, I think it would be better to do this kind of parsing with JavaScript. However, (I'm just starting with FiltaQuilla and Tb development) and don't yet know the objects or methods available to accomplish this task:
( Pseudo-code )
const hdrSubject = get_nsIMsgDbHdr(currentMailItem,"subject")
const {topic, domain} = getDomainFromRecognizedSubject(hdrSubject)
if(topic) {
const objFolder = createFolderForTopic(topic,domain)
const saveSuccess = saveToFolder(objFolder,currentMailItem)
return
}
If JS called from filtaQuilla can handle this then I'm going on a quest to create the code that implements those functions.
If this cannot be done yet, then I'll restructure the folder system or use some other code to generate folders.
I understand it's tough to generate folders asynchronously while new mail is being processed. So as an alternative I might file all recognized mail into a folder and then run manual filters on the folder later to sort it all out.
I hope that makes sense.
( Edited to correct a couple typos )
Good efforts - I can give you more help when I am back from my holidays. (1st of August).
Bear in mind that many of the functions dealing with files are (or will be converted to) asynchronous. The pattern of using an asynchronous filter is actually quite simple:
async function generateFoo() {
doSomethingExpensive(); // this could be a function parsing out a file name and then creating a
// folder, based on conditions retrieved from reading email contents, which can take a while...
await createFolders(); // assuming createFolder is also an async function - let me research that seperately
return folder;
}
await generateFoo();
moveMails(folder);
one big caveat - you cannot use await outside of a function that is not async itself. This is one of the difficulties that makes conversion from legacy code web extensions API so hard. the other thig we should try and find out is whether the FiltaQuilla Javascript action can be done in a way so that it has access to the API namespace. I hope it is possible but I would assume that you do not get full permissions to all APIs, in the best case scenario the script should inherit all permissions from FQ itself.
Unfortunately there is one thing I have to add (and had almost forgotten about) you cannot await an async function from a synchronous function, and filter actions +search terms have to be synchronous by design. Se we really need Thunderbird to modify the underlying architecture as soon as we want to write async code.
Is it possible to let FiltaQuilla sort incoming mails into local folders, depending on versatile parts of the text in the mail subject? For example: The subject contains "Mail for Jane Doe" and the mail is automatically sorted into the local folder "Mails Jane Doe"?
! And this not only for Jane Doe, but for any name that can be found by "Mail for N"? --> Sorting into folder "Mails N"?