RealRaven2000 / quickFilters

Thunderbird Add-on: quickFilters
http://quickfilters.quickfolders.org/
Other
46 stars 11 forks source link

Support triggering assistant through: deleting mail / flagging mail as junk / archiving #145

Closed RealRaven2000 closed 1 year ago

RealRaven2000 commented 1 year ago

Since v5.7.1. moving mail to Junk or Trash will categorically not invoke the active filter assistant. I believe older versions were more nuanced and would do different things depending on whether mail was moved / dragged or marked as junk / trash can clicked.

We will reintroduce the ability for these 2 special folders (Trash / Junk) to trigger the assistant, based on a user preference (UI to be built later).

RealRaven2000 commented 1 year ago

Good news is it doesn't crash and it seems to create a filter. HOWEVER, the items I drag to the trash remain in their source folder. The assistant seems to prevent moving things into the trash. After the filter was created I had to turn off the assistant and then drag the items to the trash.

This is weird, it works for me. have you go the setting to ignore the trash folder switched on or off?

image

image

Please check whether this is set to false or true. Can you see any messages in error console (Ctrl+Shift+J) when you drag emails to the trash folder? Do you drag the mails or hit the [DEL] key?

bobkatz24bit commented 1 year ago

Hi, Axel.

On 1/31/23 2:49 PM, RealRaven2000 wrote:

Good news is it doesn't crash and it seems to create a filter. HOWEVER, the items I drag to the trash remain in their source folder. The assistant seems to prevent moving things into the trash. After the filter was created I had to turn off the assistant and then drag the items to the trash.

This is weird, it works for me. have you go the setting to ignore the trash folder switched on or off?

OK, in actions I had some checkboxes different than you. I set them the same as your image below EXCEPT for "Listen for tag changes" which I left off. For some reason a tag change keeps on moving a file back and forth between one folder and another according to my filters.

But matching up your checkboxes does not help the "no trash" bug.

I checked the advanced preferences  and yes, that element extensions.quickfilters.assistant.exclude.archive is definitely set to false.

Sorry, Bob

RealRaven2000 commented 1 year ago

I checked the advanced preferences and yes, that element extensions.quickfilters.assistant.exclude.archive is definitely set to false.

I think the only relevant setting here is extensions.quickfilters.assistant.exclude.trash . The checkboxes on the "Actions" page shouldn't really matter. Do you get any messages in error console when you delete?

Press Ctrl+Shift+J to see the error console, clear its output before you delete an email.

bobkatz24bit commented 1 year ago

Guys, here's the error console readout.

Steps taken:

quickFilters {MSGMOVE} 18:45:45.443 [13523813 ms] onFolderTreeViewDrop
quickFilters {CREATEFILTER} 18:45:45.443 [0 ms] Message(***@***.***/INBOX/Prefiltered 
Inboxes/Hold - possible spam#76229 target folder=Trash message 
***@***.*** 
author="Evan Smith" ***@***.***> subject=Financing 
pre-approved for Robert ***@***.***> filterAction=-- 
cc= bcc= author="Evan Smith" ***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.443 [0 ms] Message( 
***@***.***/INBOX/Prefiltered 
Inboxes/Hold - possible spam#76227 target folder=Trash message 
***@***.*** 
author=Emily Williams ***@***.***> subject=2023 Blog & 
Influencer List - Free Sample ***@***.*** 
filterAction=-- cc= bcc= author=Emily Williams ***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.443 [0 ms] Message( 
***@***.***/INBOX/Prefiltered 
Inboxes/Hold - possible spam#76225 target folder=Trash message 
***@***.*** 
author="Dennis Cage., Sr. Underwriter, First Union" 
***@***.***> subject=Robert Katz, Supercharge your 
business with New Low-Cost Term Loans and Lines Credit (LOC) 
recipients=Robert Katz ***@***.***> filterAction=-- cc= bcc= 
author="Dennis Cage., Sr. Underwriter, First Union" 
***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.443 [0 ms] Message( 
***@***.***/INBOX/Prefiltered 
Inboxes/Hold - possible spam#76226 target folder=Trash message 
***@***.*** author=Nextdoor 
***@***.***> subject=Hey, Robert! You've got 20+ 
unread notifications ***@***.*** filterAction=-- cc= 
bcc= author=Nextdoor ***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.443 [0 ms] Message( 
***@***.***/INBOX/Prefiltered 
Inboxes/Hold - possible spam#76228 target folder=Trash message 
***@***.*** author="Serys" 
***@***.***> subject=Serys Energie 
***@***.*** filterAction=-- cc= bcc= author="Serys" 
***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.444 [1 ms] Message( 
***@***.***/INBOX/Prefiltered 
Inboxes/Hold - possible spam#76224 target folder=Trash message 
***@***.*** author=Trademarkdove 
***@***.***> subject=Start Your Business Legally 
and Protect its Good Standing to Avoid Penalties 
***@***.***" ***@***.***> filterAction=-- cc= 
bcc= author=Trademarkdove ***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.444 [0 ms] Message( 
sourceFolder=Hold - possible spam target folder=Trash message 
***@***.*** 
author="Evan Smith" ***@***.***> subject=Financing 
pre-approved for Robert ***@***.***> filterAction=1 
cc= bcc= author="Evan Smith" ***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.444 [0 ms] Message( [Trash] restore 
messageList[0] Id 
***@***.*** target 
folder=Trash message 
***@***.*** 
author="Evan Smith" ***@***.***> subject=Financing 
pre-approved for Robert ***@***.***> filterAction= 
cc= bcc= author="Evan Smith" ***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.445 [1 ms] Message( [Trash] restore 
messageList[1] Id 
***@***.*** 
target folder=Trash message 
***@***.*** 
author=Emily Williams ***@***.***> subject=2023 Blog & 
Influencer List - Free Sample ***@***.*** 
filterAction= cc= bcc= author=Emily Williams ***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.445 [0 ms] Message( [Trash] restore 
messageList[2] Id 
***@***.*** target 
folder=Trash message 
***@***.*** 
author="Dennis Cage., Sr. Underwriter, First Union" 
***@***.***> subject=Robert Katz, Supercharge your 
business with New Low-Cost Term Loans and Lines Credit (LOC) 
recipients=Robert Katz ***@***.***> filterAction= cc= bcc= 
author="Dennis Cage., Sr. Underwriter, First Union" 
***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.446 [1 ms] Message( [Trash] restore 
messageList[3] Id ***@***.*** target 
folder=Trash message ***@***.*** 
author=Nextdoor ***@***.***> subject=Hey, Robert! 
You've got 20+ unread notifications ***@***.*** 
filterAction= cc= bcc= author=Nextdoor ***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.446 [0 ms] Message( [Trash] restore 
messageList[4] Id ***@***.*** target 
folder=Trash message ***@***.*** 
author="Serys" ***@***.***> subject=Serys Energie 
***@***.*** filterAction= cc= bcc= author="Serys" 
***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.447 [1 ms] Message( [Trash] restore 
messageList[5] Id ***@***.*** target 
folder=Trash message ***@***.*** 
author=Trademarkdove ***@***.***> subject=Start 
Your Business Legally and Protect its Good Standing to Avoid Penalties 
***@***.***" ***@***.***> filterAction= cc= 
bcc= author=Trademarkdove ***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.447 [0 ms] Starting source folder validation for [xpconnect wrapped (nsIMsgFolder, 
nsISupportsWeakReference, nsIMsgImapMailFolder)]
quickFilters {CREATEFILTER} 18:45:45.447 [0 ms] Validation passed: 
server of sourceFolder Hold - possible spam can have filters
quickFilters {CREATEFILTER} 18:45:45.447 [0 ms] messageList.length = 6
quickFilters {CREATEFILTER} 18:45:45.447 [0 ms] got msg; messageKey=76229
quickFilters {CREATEFILTER} 18:45:45.447 [0 ms] Message( messageKey=76229 target folder=Trash message 
***@***.*** 
author="Evan Smith" ***@***.***> subject=Financing 
pre-approved for Robert ***@***.***> filterAction=1 
cc= bcc= author="Evan Smith" ***@***.***>)
quickFilters {CREATEFILTER} 18:45:45.447 [0 ms] parsing msg header...
quickFilters {CREATEFILTER} 18:45:45.447 [0 ms] emailAddress = 
***@***.***, ccAddress = , bccAddress=
quickFilters {CREATEFILTER} 18:45:45.447 [0 ms] message header parsed.
quickFilters {CREATEFILTER} 18:45:45.447 [0 ms] previewText=(844) 
220-3232 Hi Robert, I am thrilled to let you know based on our research 
data, Digital Domain Inc could be pre-approved for up to $440,000 for 
our new Express Business LOC. This line of credit allows small 
businesses immediate access to capit
quickFilters [logTime init] Merge filter: Selecting merge as default
quickFilters 18:45:45.521 [0 ms] remove replyto item from template list...
quickFilters 18:45:45.521 [0 ms] selectTemplateFromListTimer()
PotatoCarl commented 1 year ago

Hi, acutally no email is moved. When I move an email from another folder to e.g. Inbox, the filter assistant pops up, but the message is not moved. When I turn off QuickFilters, the message is moved as expected.

RealRaven2000 commented 1 year ago

Hi, acutally no email is moved. When I move an email from another folder to e.g. Inbox, the filter assistant pops up, but the message is not moved. When I turn off QuickFilters, the message is moved as expected.

All very weird, cannot reproduce this, is the target Inbox in local folders / Imap account / POP3 account? What are your settings on the first tab of quickFilters? Can you capture an error log (with Ctrl+Shift+J) ? Do you see any errors there when dropping the mails?

PotatoCarl commented 1 year ago

Is is an IMAP account. Here's the log.

->->-> quickFilters {MSGMOVE} 11:16:24.458 [31895 ms]
onFolderTreeViewDrop quickFilters [logTime init] selectTemplateFromListTimer() -<-<-<

No error message. Filter dialog pops up, message is where it is.

Moving within an IMAP-Tree from a public account INBOX to my own INBOX (IMAP). Worked with the previous version without problems. Works when turning off QuickFilter.

RealRaven2000 commented 1 year ago

I can reproduce it, it's probably to do with the original treeview-drop routine. Will post a new version here ASAP.

outfox60 commented 1 year ago

Leaving comment so I can be notified when there is a solution... :)

bobkatz24bit commented 1 year ago

Thanks, Axel!

Bob

On 2/1/23 2:06 PM, RealRaven2000 wrote:

I can reproduce it, it's probably to do with the original treeview-drop routine. Will post a new version here ASAP.

RealRaven2000 commented 1 year ago

I am halfway there but getting some duplicate assistants now on some operations (archiving, moving to a QuickFolders tab). The difficult thing will be to fix it without necessitating a new version of QuickFolders as well. Will post a new version tomorrow.

PotatoCarl commented 1 year ago

Hi not sure if anybody else saw this: if I select multiple emails I cannot move them either (they are not moved, but the filter pops up). that worked before, too. QuickFilter: 5.8pre68

RealRaven2000 commented 1 year ago

Hi not sure if anybody else saw this: if I select multiple emails I cannot move them either (they are not moved, but the filter pops up). that worked before, too.

I will look out for that today as well - could you edit your post and add the quickFilters version number please?

RealRaven2000 commented 1 year ago

Alright here is a newer version. Still having some problems with intermittent failure when dropping emails to a QuickFolder submenu (in IMAP). Otherwise, seems to be stable for now:

quickFilters-wx-5.8pre84.zip

Tested:

To install this preview version:

RealRaven2000 commented 1 year ago

Found another bug when I tested moving via Thunderbird context menu (Exception targetFolder not found), so here is with that bugfix:

quickFilters-wx-5.8pre85.zip

To install this preview version:

bobkatz24bit commented 1 year ago

Congratulations, Axel!!! And thanks for your fine work. This morning I tried pre84, dragged some emails to the Trash and they went there and the filter create/merge dialogues all came up.

Thank you, Bob

bobkatz24bit commented 1 year ago

Thanks again, Axel. Pre85 works well when dragging mails to the trash.

I HAVE A QUESTION: When merging with an existing filter does Thunderbird/Quickfilters examine existing criteria and prevent duplicate criteria? For example, I'm creating filters that send certain senders to the Trash automatically. I still get some spam despite using an external spam filtering service! At this point I have at least 12 filters that send certain senders to the trash -- each filter has many senders in the list. I arbitrarily create a new filter whenever I feel there are a lot of senders in any existing filter, just because it feels like a good idea. I'm also wondering if Thunderbitd can get "overloaded" with so many names in filters. I am not using Thunderbird's built in junk utility as I don't want automatic Bayseian filtering, I just want a white and black list.

Oh by the way, I have finally kind of conquered spam. I examine a "hold" folder every morning and there aren't usually more than 5 or 10 to examine and sort through. Some of them I need to keep and some I need to trash. It's the last "human" intervention left in my system :-)

Bob

RealRaven2000 commented 1 year ago

Congratulations, Axel!!! And thanks for your fine work. This morning I tried pre84, dragged some emails to the Trash and they went there and the filter create/merge dialogues all came up.

I might also add a routing for the delete button / Edit - Delete Message for those who want to use the keyboard. Would this be ok / potentially useful?

RealRaven2000 commented 1 year ago

When merging with an existing filter does Thunderbird/Quickfilters examine existing criteria and prevent duplicate criteria?

Yes, it should do that (if you are filtering by sender, this will be based on the email address)

I arbitrarily create a new filter whenever I feel there are a lot of senders in any existing filter, just because it feels like a good idea. I'm also wondering if Thunderbit can get "overloaded" with so many names in filters.

In my experience the answer is probably yes. It is not well tested for >100 search conditions and may lead to performance problems. Better to break it up once you reach 40 or 50 conditions. You can use the "Sort" button to check for duplicates!

Oh by the way, I have finally kind of conquered spam. I examine a "hold" folder every morning and there aren't usually more than 5 or 10 to examine and sort through. Some of them I need to keep and some I need to trash.

Well done. If you want to do me a big favor, could you answer the github mail on the website (rather than sending a reply from Thunderbird) - it always creates a lot of extra stuff / information I need to delete in your posts otherwise. (Hence you see the note that your posts were "Edited by RealRaven"). Github has a great built in Markdown editor that even allows inserting of screenshots and necessary formatting. We always have to remember that whatever we reply here will be sent to everybody who is subscribed to the particular issue.

bobkatz24bit commented 1 year ago

Personally I don't use many keystrokes in Thunderbird. I'm sure someone wants to use the keyboard delete.

Bob

RealRaven2000 commented 1 year ago

Just a technical note on supporting DEL key and menu item. If implemented, these could be using the action "Delete EMail" rather than "move to (particular) Trash" folder. This should probably also be used when a user drags mail to Trash on the same account / server.

The big difference here would be that if you copied the filter across to a different account it would behave more along the expected line of deleting mail within the account (rather than sending the mail across to the Trash folder on another account! Because at the moment when you delete mail by dragging it to trash all copies of the filter will always try to move it to the same Trash box - regardless of on which account you used it)

Thoughts?

bobkatz24bit commented 1 year ago

I guess you are speaking of creation of a NEW filter. I have a bunch of existing filters that I am merging with, each filter currently has the single action "Move Message to ---- Trash". So if I pick to merge with an existing filter the new filter items will also move to the trash.

So basically I think you are saying that if I use the Delete Email action instead of "Move to ----- trash" the filter I create will be more universally applicable to a different email account, etc.

RealRaven2000 commented 1 year ago

I guess you are speaking of creation of a NEW filter. I have a bunch of existing filters that I am merging with, each filter currently has the single action "Move Message to ---- Trash". So if I pick to merge with an existing filter the new filter items will also move to the trash.

So basically I think you are saying that if I use the Delete Email action instead of "Move to ----- trash" the filter I create will be more universally applicable to a different email account, etc.

Yes that's the idea. I could make "Drag to Trash" behave the same way, but merging might probably not suggest the existing filter based on that action (as it is a different action from the perspective from a filter). So it might be a good idea to do a merge check as well and offer that, but that's potentially adding some complication to the flow. When the filter process is started (let's say somebody hits DEL) I usually transmit the action (in this case not "move to folder trash" but "delete mail") and I would have to add some extra logic to still match that with existing filters that "move mail to (this particular) trash folder".

If the user would choose to merge in this case, it would have to change the action from "delete" to "move to trash". Something to keep in mind. I am still investigating as there is no global function for delete message but it's a command handler so I would have to monkey wrap the global command handler that's in charge for this command:

    var controller = top.document.commandDispatcher.getControllerForCommand("cmd_delete");
    controller.doCommand = myNewCommandHandler;

... and restore the original function when quickFilters shuts down. Going to check with @jobisoft on the Dev call tonight whether that's feasible.

bobkatz24bit commented 1 year ago

Sounds like you're going through tremendous effort for potentially little benefit. In my case I might not like triggering filters with the DEL key, I probably would continue to drag to the trash. So, of course, please add DEL to the optional triggers in the QuickFilters Assistant setup box. Many thanks!

PotatoCarl commented 1 year ago

@bobkatz24bit Just to comment on this: I do not mistreat animals if I do not have to, so I rather use the keyboard instead of forcing my mouse to run around the screen and move heavy mails...

bobkatz24bit commented 1 year ago

Cute. My mouse is a Wacom tablet. Dragging with the tablet is not a drag. I am very much a heavy keyboard/keystroke user. I just can't keep all the keystrokes for all my applications and computers in my head so sometimes I "mouse it". :-)

RealRaven2000 commented 1 year ago

Here is a new version that also supports creating a new filter / merging (using assistant) when deleting emails (via DEL button or context menu). Note that the action in this case is now "Delete Message" and not "Move to folder .../trash", which is the more correct way to implement this sort of filter action.

quickFilters-wx-5.8pre101.zip

To install preview version:

bobkatz24bit commented 1 year ago

A nice observation: Pre101 seems faster in operation than previous Quickfilter versions. It successfully merges with an existing filter if I choose merge. It successfully recognizes when I drag files to the trash and that's the action created in a new filter if I drag. It successfully recognizes when I hit DEL and that's the action created when I delete files and create a new filter. And sigh of relief: the files do end up in the trash upon deleting. It's always better to have the trash until the user decides to empty the trash.

Bottom line: All the actions that I've tested have been successful with Pre 101.

RealRaven2000 commented 1 year ago

Implemented in 5.8, released on 15/02/2023

bobkatz24bit commented 1 year ago

Dear Axel: I have recently lost the ability to select all in Thunderbird. The hotkey (command-A) on mac no longer works. The edit menu shows select ---> all, but it doesn't do anything. Could this be related to the quickfilter changes?

RealRaven2000 commented 1 year ago

Dear Axel: I have recently lost the ability to select all in Thunderbird. The hotkey (command-A) on mac no longer works. The edit menu shows select ---> all, but it doesn't do anything. Could this be related to the quickfilter changes?

This was fixed in version 5.8.1, released on 18/02/2023 see issue #160