Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RealRaven2000 opened this issue Dec 29, 2022 · 81 comments
Assignees
Labels

Comments

@RealRaven2000
Copy link
Owner

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 RealRaven2000 self-assigned this Dec 29, 2022
@RealRaven2000
Copy link
Owner Author

Here is a test version - this one enables the assistant for junk and trash:

quickFilters-wx-5.7.2pre2.zip

however these can be disabled through the config settings

extensions.quickfilters.assistant.exclude.trash = true
extensions.quickfilters.assistant.exclude.junk = true

I am planning to build a UI around these special assistant options later. To install the version above, download the zip file and then drag the file into Thunderbird Agd-ons Manager (do not extract contents).

@PotatoCarl
Copy link

I used Pre9 with #143 and it works on delete but not for archiving. The two config settings cannot be found in the configuration here (neither in the thunderbird, nor in the debug settings directly accessible from the addon).

@RealRaven2000 RealRaven2000 changed the title Support triggering assistant through deleting mail or flagging mail as junk Support triggering assistant through: deleting mail / flagging mail as junk / archiving Jan 2, 2023
@RealRaven2000
Copy link
Owner Author

RealRaven2000 commented Jan 2, 2023

@PotatoCarl - here is a new preview version:

quickFilters-wx-5.7.2pre9.zip

I provided a very primitive interface for unsetting the flag (that by default will ignore archived messages). Open quickFilters Settings, and on the actions screen click on the button "Folders to ignore Assistant..."

image

This will display a filtered view of about:config. There you can change the setting:

extensions.quickfilters.assistant.exclude.archive=false

image

...then archiving messages will trigger the assistant (unless you already have a matching rule set up that could have archived the message automatically)

To install the prerelease version, download the zip file and drag it into Thunderbird Add-ons manager without extracting the contents.

@PotatoCarl
Copy link

Hi
The behaviour changed now:
If I delete a message (pressing DEL) now the filter assistant pops up. This was not the case in the previous version. When switching the exclude setting to exclude the Trash folder, the assistant is not triggered.
If I archiv a message, the filter assistant pops up, independend of the setting of the "exclude.archive" setting.
If I mark a message as junk, the assistant does NOT pop up (exclude setting for junk "true"). However, when I unmark it in the JUNK folder, it pops up.

Remark: My Archiv Settings form Thunderbird are set to "archive by years", so the folder structure is Archiv/

@RealRaven2000
Copy link
Owner Author

If I delete a message (pressing DEL) now the filter assistant pops up. This was not the case in the previous version. When switching the exclude setting to exclude the Trash folder, the assistant is not triggered.

This is right - and now by design. because the folder listener cannot distinguish between the cases of whether the user dragged an email into the trash, hit the DEL button or used some other method (such as using a quickMove operation by QuickFolders). It won't even know whether a filter deleted the email. So there is only triggering the assistant or not, which is reflected in the setting extensions.quickfilters.assistant.exclude.trash. This is the price I had to pay for removing the monkey patched functions that overwrote internal Thunderbird functions for the various possible user actions and then in turn could make a more qualified / nuanced decision whether the assistant would be triggered or not.

If I archiv a message, the filter assistant pops up, independend of the setting of the "exclude.archive" setting.

Strange I cannot confirm, using 5.7.2pre9, the assistant is not triggered if I archive (using the [A] key or dragging into the Archives folder) are you dragging it somewhere else (maybe a subfolder in Archives) or use yet another method of archiving?

For reference - this is what my archives folder looks like:

image

If I mark a message as junk, the assistant does NOT pop up (exclude setting for junk "true"). However, when I unmark it in the JUNK folder, it pops up.

By design so this on is working for you correctly.

@PotatoCarl
Copy link

So, I checked my "Archive Options" (account settings) and switched it to "one folder". But still, whenever I Archive a message, the filter pops up.
Besides, Thunderbird ignores the setting here and creates a folder with the year to which the message is stored.
I personally hate using the "A" key, as sometimes Thunderbird hangs and when I type blindly as usual it shoots a dozen mails into Archive.... So I reconfigured with TbKeys the Archive key to "INS".
An it is independend if using the key or the menu option "Archive".
However, I would propose to allow all built-in options that Archiving offers (I believe at some time the defaults was "one folder per month").

@RealRaven2000
Copy link
Owner Author

I tried setting a yearly archive in my test account, using this option
image

IF I archive a message it goes to Archives / 2022 and the assistant is still triggered (provided I do not exclude the archive setting). quickFilters uses the built in folder flags in order to determine whether a folder is an archive folder or not, so it should only be disabled if the flag is set and the exclusion is set to false. Otherwise the folder should just be treated like an ordinary folder and trigger the assistant. If you check the error console is there a message why it is omitted? There could already be a filter that was expected to archive the message automatically (in which case the assistant is not be triggered). Error console should tell us this especially if quickFilters debug mode is enabled. See quickFilters settings / advanced:

image

@PotatoCarl
Copy link

The following gest logged:

msgsMoveCopyCompleted()

Object { isMoved: true, aSrcMsgs: (1) […], targetFolder: XPCWrappedNative_NoHelper, aDestMsgs: (1) […] }
quickFilters.js:1388:15
moved 1 messages, now invoking filter assistant... quickFilters.js:1467:19
Diese Seite befindet sich im Kompatibilitätsmodus (Quirks). Das Seitenlayout kann beeinflusst werden. Verwenden Sie für den Standardmodus "". fetch>UID>.INBOX>355702
Layout-Darstellung wurde erzwungen, bevor die Seite vollständig geladen war. Falls Stylesheet noch nicht geladen sind, kann dies zu einem kurzzeitigen Darstellung des Inhalts ohne Formatierung führen. contentAreaClick.js:97:6
downloadable font: failed to start download (font-family: "MarriottFont" style:normal weight:400 stretch:100 src index:0): content blocked source: https://cache.marriott.com/aka-fonts/Sheraton/GT-Super-Display-Light.otf
quickFilters [logTime init]
selectTemplateFromListTimer()

@PotatoCarl
Copy link

FYI: I am doing everything on my IMAP server including Archiving. So I do not Archiv to local folders.

@RealRaven2000
Copy link
Owner Author

Object { isMoved: true, aSrcMsgs: (1) […], targetFolder: XPCWrappedNative_NoHelper, aDestMsgs: (1) […] }
quickFilters.js:1388:15
moved 1 messages, now invoking filter assistant... quickFilters.js:1467:19

It sounds like the assistant should actually be showing, at least with current versions of Thunderbird 91 / 102. Are you using a beta version?

@PotatoCarl
Copy link

It is showing, that is exactly my problem. I am archieving messages, so they are moved where they are supposed to go and I do not want the assistent to make a filter for me.

@RealRaven2000
Copy link
Owner Author

It is showing, that is exactly my problem. I am archieving messages, so they are moved where they are supposed to go and I do not want the assistent to make a filter for me.

If you do not want the assistant to pop up during archiving, please reset the setting to its default (true):

extensions.quickfilters.assistant.exclude.archive=true

in this context assistant.exclude means not to trigger the assistant for folders with the particular flag (archive)

image

@PotatoCarl
Copy link

As you can see, the setting is activated. Still, the assistant pops up
grafik

@RealRaven2000
Copy link
Owner Author

Here is a test version with additional log output:
quickFilters-wx-5.7.2pre14.zip

Please set Debug Mode = active and
extensions.quickfilters.debug.msgMove = true

  • then capture the console output that happens when you archive a message and it triggers the assistant. This will print out folder URI and flags so I can check what they are.

@PotatoCarl
Copy link

Okay, this is funny: You will see that I archived TWO emails. The first one was sorted under Archives - no Assistant popped up.
The second was archived under Archiv/2023 - The assistant popped up.

As It was directly after each other, and I did not change anything in between I have no understanding why they are treated differently and why at one time the assistant pops up and on another not.

msgsMoveCopyCompleted()

Object { isMoved: true, aSrcMsgs: (1) […], targetFolder: XPCWrappedNative_NoHelper, aDestMsgs: (1) […] }
quickFilters.js:1388:15
No Assistant triggered for excluded target folder: Archiv
Flags: 0x10086014
URI: imap://tbrandau@mail.brace.de/INBOX/Archives quickFilters.js:1410:19
Diese Seite befindet sich im Fast-Standards-Modus ("almost standards mode"). Das Seitenlayout kann beeinflusst werden. Verwenden Sie für den Standardmodus "". {146b5d34-c6a8-4ff2-8e0b-4c1f25e7269f}
Diese Seite befindet sich im Fast-Standards-Modus ("almost standards mode"). Das Seitenlayout kann beeinflusst werden. Verwenden Sie für den Standardmodus "". blank
Diese Seite befindet sich im Kompatibilitätsmodus (Quirks). Das Seitenlayout kann beeinflusst werden. Verwenden Sie für den Standardmodus "". fetch>UID>.INBOX>355812
msgsMoveCopyCompleted()

Object { isMoved: true, aSrcMsgs: (1) […], targetFolder: XPCWrappedNative_NoHelper, aDestMsgs: (1) […] }
quickFilters.js:1388:15
Assistant triggered for folder 2023
XPCWrappedNative_NoHelper { QueryInterface: QueryInterface(), URI: Getter, name: Getter & Setter, prettyName: Getter & Setter, abbreviatedName: Getter, setPrettyNameFromOriginal: setPrettyNameFromOriginal(), parent: Getter & Setter, messages: Getter, Init: Init(), startFolderLoading: startFolderLoading(), … }

flags: 0x18082014
URI: imap://tbrandau@mail.brace.de/INBOX/Archives/2023 quickFilters.js:1418:17
moved 1 messages, now invoking filter assistant... quickFilters.js:1473:19
Diese Seite befindet sich im Kompatibilitätsmodus (Quirks). Das Seitenlayout kann beeinflusst werden. Verwenden Sie für den Standardmodus "". {bcec75d8-3506-4468-b109-963aeb4edf96}
Diese Seite befindet sich im Kompatibilitätsmodus (Quirks). Das Seitenlayout kann beeinflusst werden. Verwenden Sie für den Standardmodus "". blank
Diese Seite befindet sich im Kompatibilitätsmodus (Quirks). Das Seitenlayout kann beeinflusst werden. Verwenden Sie für den Standardmodus "". fetch>UID>.INBOX>355795
quickFilters [logTime init]
selectTemplateFromListTimer()

@RealRaven2000
Copy link
Owner Author

Thanks, so the first folder (Archives) has flags 0x10086014, which according to flags reference is comprised of:

0x10086014 = 0x10000000 | 0x80000 | 0x4000 | 0x2000 | 0x10 | 0x04
0x10000000 (OfflineEvents)
0x80000 (ImapPersonal)
0x4000 (Archive)
0x2000 (ImapBox)
0x0010 (Elided)
0x0004 (Mail)

The second folder (Archives/2023) has the flags 0x18082014 which is comprised of:

0x18082014 = 0x10000000 | 0x8000000 | 0x80000 | 0x2000 | 0x10 | 0x04
0x10000000 (OfflineEvents)
0x8000000 (Offline)
0x80000 (ImapPersonal)
0x2000 (ImapBox)
0x0010 (Elided)
0x0004 (Mail)

so indeed - these subfolders have not got the Archive flag. Not sure whether this is a bug or by design in the Thunderbird implementation.

@PotatoCarl
Copy link

Well, I desperately deleted the folders (2023...) but Thunderbird recreates them when Archiving.
An I am also stunned, why two times doing the same gives different results...
I cannot change the flags, or at last do not know how.

@RealRaven2000
Copy link
Owner Author

Well, I desperately deleted the folders (2023...) but Thunderbird recreates them when Archiving. An I am also stunned, why two times doing the same gives different results... I cannot change the flags, or at last do not know how.

Could you move the Archives folder out of Inbox to the root of the account?

@RealRaven2000
Copy link
Owner Author

Strangely, I couldn't set yearly archives on my (gmail) Imap account, only if I chose "Archive in Local Folders". Otherwise the "Archive Options" button remains disabled.

@RealRaven2000
Copy link
Owner Author

Strangely, I couldn't set yearly archives on my (gmail) Imap account, only if I chose "Archive in Local Folders". Otherwise the "Archive Options" button remains disabled.

maybe because the folder already contains data? I will check that next...

@RealRaven2000
Copy link
Owner Author

Ok, so the only strategy I can come up with right now is to also check the tree of parent folders, then check whether the parent has the archive flag. Patch code:

      const isArchiveExcluded = qF.Preferences.getBoolPref("assistant.exclude.archive");
      if (isArchiveExcluded) {
        excluded = excluded | FLG.Archive; // main (Archive) folder
      }
      if (isArchiveExcluded) {  // exclude all Archive child folders
        let p = targetFolder;
        while (p) {
          p = p.parent;
          if (!p || p.isServer) break;
          if (p.flags | FLG.Archive) {
            console.log(`Disabled Assistant for folder:  ${targetFolder.prettyName} \nIt is in an Archived parent folder.\nFlags: 0x${p.flags.toString(16)}\nURI: ${p.URI}`);
            return;
          }
        }
      }

Patched version below:
quickFilters-wx-5.7.2pre15.zip

To install the prerelease version, download the zip file and drag it into Thunderbird Add-ons manager without extracting the contents.

@RealRaven2000
Copy link
Owner Author

Translated new button to 18 languages:

quickFilters-wx-5.7.2pre18.zip

To install the prerelease version, download the zip file and drag it into Thunderbird Add-ons manager without extracting the contents.

@PotatoCarl
Copy link

maybe because the folder already contains data? I will check that next...

No, it is empty.

@PotatoCarl
Copy link

Could you move the Archives folder out of Inbox to the root of the account?

It is in the root. We are running our own cyrus server in house, so no Gmail or so.

@RealRaven2000
Copy link
Owner Author

Could you move the Archives folder out of Inbox to the root of the account?

It is in the root. We are running our own cyrus server in house, so no Gmail or so.

Weird, according to your own log:

imap://tbrandau@mail.brace.de/INBOX/Archives

There is a big INBOX folder above it. Anyway, did you try prerelease 18?

@PotatoCarl
Copy link

Weird, according to your own log:

imap://tbrandau@mail.brace.de/INBOX/Archives

Well this is the root of the account like Cyrus is handling those. I do not get a "xxxyy@domain/INBOX//Archiv" but "xxxyy@domain//ARCHIV/" folder. The INBOX naming in the log is irritating, as there is no level above it.

There is a big INBOX folder above it. Anyway, did you try prerelease 18?

INBOX is the root of my account. Also with other configured accounts "Posteingang" is always pointing to "INBOX" here (or at Strato etc.). Due to the Cyrus configuration, all users are on the same level, so matter of fact, whatever Thunderbird names "INBOX" is the user name on IMAP level.

Yes I tried the new version. I used two different settings for the Archiv option, "one folder" and "one folder per year" and in neither case the assistant popped up. So it seems to work.

Thank you for your quick action as always.

@PotatoCarl
Copy link

well, the Pre18 version does not popup the assistant when archiving... however it does neither when sorting any other mail via Quickfolders...

@RealRaven2000
Copy link
Owner Author

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

@outfox60
Copy link

outfox60 commented Feb 1, 2023

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

@bobkatz24bit
Copy link

bobkatz24bit commented Feb 1, 2023 via email

@RealRaven2000
Copy link
Owner Author

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
Copy link

PotatoCarl commented Feb 2, 2023

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
Copy link
Owner Author

RealRaven2000 commented Feb 2, 2023

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?

  • Thanks for the edit!

@RealRaven2000
Copy link
Owner Author

RealRaven2000 commented Feb 2, 2023

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:

  • dropping mail to folder tree
  • dropping mail to a QuickFolders Tab
  • dropping mail to a QuickFolders subfolder
  • using the QuickFolders quickMove function
  • archiving mail (By using the context menu, shortcut A)

To install this preview version:

  • download the zip file
  • drag the zip file into Thunderbird Add-ons Manager (do not extract contents)

@RealRaven2000
Copy link
Owner Author

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:

  • download the zip file
  • drag the zip file into Thunderbird Add-ons Manager (do not extract contents)

@bobkatz24bit
Copy link

bobkatz24bit commented Feb 2, 2023 via email

@bobkatz24bit
Copy link

bobkatz24bit commented Feb 2, 2023 via email

@RealRaven2000
Copy link
Owner Author

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
Copy link
Owner Author

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
Copy link

bobkatz24bit commented Feb 2, 2023 via email

@RealRaven2000
Copy link
Owner Author

RealRaven2000 commented Feb 2, 2023

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
Copy link

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
Copy link
Owner Author

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
Copy link

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
Copy link

@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
Copy link

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
Copy link
Owner Author

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:

  • download the zip file
  • drag the zip file into Thunderbird Add-ons Manager (do not extract contents)

RealRaven2000 added a commit that referenced this issue Feb 7, 2023
@bobkatz24bit
Copy link

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
Copy link
Owner Author

Implemented in 5.8, released on 15/02/2023

@bobkatz24bit
Copy link

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
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants