RealRaven2000 / FiltaQuilla

Adds many new mail filter actions to Thunderbird
http://quickfilters.quickfolders.org/filtaquilla.html
GNU General Public License v3.0
88 stars 17 forks source link

Filter to delete message without moving to trash, not working #315

Open cyberroneous opened 3 days ago

cyberroneous commented 3 days ago

I'd been searching around for an option to have Thunderbird fully delete a message the instant it's received, without moving to trash or notifying, as though it never even arrived in the first place, if it matches certain criteria. For example, from a blacklisted/spam originating address.

The only productive discussion I could find about a way to actually do this, is from this forum back in 2011:

https://forums.mozillazine.org/viewtopic.php?t=2257469

In it, the suggestion to use FiltaQuilla with the "javascript action (with body)" option is made, specifically the code below supplied by the first author of the extension:

msgHdrs.queryElementAt(0, Ci.nsIMsgDBHdr).folder.deleteMessages(msgHdrs, msgWindow, true, false, null, false);

It was reported as working by the OP at the time, using the then-current versions of TB and FQ. However at present trying to implement the above code fails with an error.

Is there a modern version of this custom filter code that will work with Thunderbird v78 forward?

Thanks.

RealRaven2000 commented 3 days ago

I'd been searching around for an option to have Thunderbird fully delete a message the instant it's received, without moving to trash or notifying, as though it never even arrived in the first place, if it matches certain criteria. For example, from a blacklisted/spam originating address.

The only productive discussion I could find about a way to actually do this, is from this forum back in 2011:

https://forums.mozillazine.org/viewtopic.php?t=2257469

In it, the suggestion to use FiltaQuilla with the "javascript action (with body)" option is made, specifically the code below supplied by the first author of the extension:

msgHdrs.queryElementAt(0, Ci.nsIMsgDBHdr).folder.deleteMessages(msgHdrs, msgWindow, true, false, null, false);

I think that code is wrong because msgHdrs is now an Array and not a collection, so the queryElementAt() probably fails.

Instead, can you try this (I am assuming all matching messages during the action are in the same folder) :

  msgHdrs[0].folder.deleteMessages(msgHdrs, msgWindow, true, false, null, false);
RealRaven2000 commented 3 days ago

Here is a script I tested in Thunderbird 133.0b2, should also work in 128:

var txtDebug = "", i=1;
for (var m of msgHdrs) { 
  txtDebug += `\n${i++}. ${m.subject}`;
}
console.log(`processing folder ${msgHdrs[0].folder.prettyName} - WILL DELETE: ${txtDebug}`);
msgHdrs[0].folder.deleteMessages(msgHdrs, msgWindow, true, false, null, false);

At least it leaves a trace in the console of what it did. Good luck!

cyberroneous commented 3 days ago

Hi, thanks for the quick and helpful reply. When I try to test run the modified version of the code, I get an error message the filter failed to run. I'm guessing it likely has something to do with the fact that I'm running TB version 78.14.0 on Linux, rather than the newest version? Is there a small quick change I can make to the code to make it compatible with this older version?

RealRaven2000 commented 3 days ago

Update to 115 or 128 then it will work. I cannot support such an old version.

cyberroneous commented 3 days ago

Update to 115 or 128 then it will work. I cannot support such an old version.

Of course, I totally understand. The reason I'm using an old version is that every new version after that has an odd behavioral quirk on my particular Linux distribution that is very inconvenient. Any time the screen is locked, all data connectivity is lost. So that if I receive emails while doing something else around the house, they won't be received and the sound notification won't play to let me know.

Other programs work fine and continue to maintain data transfers in the background while locked, but TB disconnects every time until I unlock the screen again.

I keep updating each time they release a new version, hoping the bug will be fixed, but no luck so far. I even posted a bug report with Mozilla ages ago but it's never been addressed. Maybe some day! Once they do fix it, I'll update and use the posted code above for FiltaQuilla. Many thanks again..!

https://bugzilla.mozilla.org/show_bug.cgi?id=1772337