paperlined.org
apps > thunderbird > FiltaQuilla
document updated 11 years ago, on Jan 8, 2013

The documentation for FiltaQuilla's more complex features is lacking. To try to help that, here is some example code.

Table of contents
  1. Header Regex Match
  2. Javascript Match
  3. Javascript Action
  4. Javascript Action with Body

Header Regex Match

sender:jslr[0-9][0-9]\.fr
recipients:/work-(.+)@abc\.com/i
subject:Case \d+ Dispatched

Per this page, some common headers are:

Javascript Match

/somename/.test( message.getStringProperty('sender') );
/somename/.test( message.getStringProperty('replyTo') );
let tags = message.getStringProperty('keywords');
(/pro/.test(tags) && !(/done/.test(tags));
let sentDate = new Date(message.date/1000);
(sentDate.getHours() >= 12 && sentDate.getHours() < 18)
Example from here:
logger = 'MESSAGE : ' + message.getStringProperty('subject') + '\n';
let evohdr = message.getStringProperty('x-evolution');
logger += 'THUNDERBIRD FLAGS BEFORE : ' + message.flags + '\n';
evostatus = evohdr.substring(evohdr.length - 4, evohdr.length);
logger += 'EVOLUTION HEXA : ' + evostatus + '\nSTATUS : \n';
var hexevostatus = parseInt(evostatus, 16);
var flags = message.flags;
deleted = false;
if (hexevostatus & 1<<0) {
  logger += '   * is answered\n';
  flags = flags | 1<<1
}
if (hexevostatus & 1<<1) {
  logger += '   * is deleted\n';
  deleted = true;
}
if (hexevostatus & 1<<3) {
  logger += '   * is marked as important\n';
  flags = flags | 1<<2
}
if (hexevostatus & 1<<4) {
  logger += '   * is read\n';
  flags = flags | 1<<0
}
if (hexevostatus & 1<<5) {
  logger += '   * has attachment(s)\n';
  flags = flags | 1<<28
}
if (hexevostatus & 1<<7) {
  logger += '   * is junk\n';
  message.setStringProperty('junkscore', 100);
  message.setStringProperty('junkscoreorigin','user');
}
if (hexevostatus & 1<<11) {
  logger += '   * has been marked as not junk (no action)\n';
}
if (hexevostatus & 1<<12) {
  logger += '   * has been forwarded\n';
  flags = flags | 1<<12
}
message.flags = flags;
logger += 'THUNDERBIRD FLAGS SET TO : ' + flags + '\n';
logger +='WILL DELETE ? : ' + deleted;
Cc["@mozilla.org/consoleservice;1"]
   .getService(Ci.nsIConsoleService)
   .logStringMessage(logger);

Javascript Action

The variables available to the function are the same as what's sent to nsIMsgFilterCustomAction::apply:

Javascript Action with Body

From here:
for (let index = 0; index < msgHdrs.length; index++)
{
  let hdr = msgHdrs.queryElementAt(index, Ci.nsIMsgDBHdr);
  hdr.subject = "[Hello, world] " + hdr.subject;
}
From here:
msgHdrs.queryElementAt(0, Ci.nsIMsgDBHdr).folder.deleteMessages(msgHdrs, msgWindow, true, false, null, false);