Bug 449747 Running Junk Mail Controls manually on Folder or message fails if multiple address books selected for whitelist. r=Standard8,sr=Neil
This commit is contained in:
Родитель
68873cf300
Коммит
87b34405ad
|
@ -187,36 +187,37 @@ MessageClassifier.prototype =
|
||||||
*
|
*
|
||||||
* @param aMsgHdr
|
* @param aMsgHdr
|
||||||
* The header (nsIMsgDBHdr) of the message to classify.
|
* The header (nsIMsgDBHdr) of the message to classify.
|
||||||
* @param aWhiteListDirectory
|
* @param aWhiteListDirectories
|
||||||
* The addressbook (nsIAbDirectory) to use as a whitelist, or null
|
* Array of addressbooks (nsIAbDirectory) to use as a whitelist, or zero
|
||||||
* if no whitelisting should be done.
|
* length if no whitelisting should be done.
|
||||||
*/
|
*/
|
||||||
analyzeMessage: function(aMsgHdr, aWhiteListDirectory)
|
analyzeMessage: function(aMsgHdr, aWhiteListDirectories)
|
||||||
{
|
{
|
||||||
var junkscoreorigin = aMsgHdr.getStringProperty("junkscoreorigin");
|
var junkscoreorigin = aMsgHdr.getStringProperty("junkscoreorigin");
|
||||||
if (junkscoreorigin == "user") // don't override user-set junk status
|
if (junkscoreorigin == "user") // don't override user-set junk status
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if a whitelist addressbook was specified, check if the email address is in it
|
// if a whitelist addressbook was specified, check if the email address is in it
|
||||||
if (aWhiteListDirectory)
|
if (aWhiteListDirectories.length)
|
||||||
{
|
{
|
||||||
var headerParser = Components.classes["@mozilla.org/messenger/headerparser;1"]
|
var headerParser = Components.classes["@mozilla.org/messenger/headerparser;1"]
|
||||||
.getService(Components.interfaces.nsIMsgHeaderParser);
|
.getService(Components.interfaces.nsIMsgHeaderParser);
|
||||||
var authorEmailAddress = headerParser.extractHeaderAddressMailboxes(null, aMsgHdr.author);
|
var authorEmailAddress = headerParser.extractHeaderAddressMailboxes(null, aMsgHdr.author);
|
||||||
var abCard = false;
|
var abCard = false;
|
||||||
try {
|
for (var abCount = 0; abCount < aWhiteListDirectories.length; abCount++)
|
||||||
abCard = aWhiteListDirectory.cardForEmailAddress(authorEmailAddress);
|
|
||||||
} catch (e) {}
|
|
||||||
if (abCard)
|
|
||||||
{
|
{
|
||||||
// message is ham from whitelist
|
try {
|
||||||
{
|
if (aWhiteListDirectories[abCount].cardForEmailAddress(authorEmailAddress))
|
||||||
var db = aMsgHdr.folder.getMsgDatabase(msgWindow);
|
{
|
||||||
db.setStringProperty(aMsgHdr.messageKey, "junkscore", Components.interfaces.nsIJunkMailPlugin.IS_HAM_SCORE);
|
// message is ham from whitelist
|
||||||
db.setStringProperty(aMsgHdr.messageKey, "junkscoreorigin", "whitelist");
|
var db = aMsgHdr.folder.getMsgDatabase(msgWindow);
|
||||||
this.mGoodMsgHdrs.appendElement(aMsgHdr, false);
|
db.setStringProperty(aMsgHdr.messageKey, "junkscore",
|
||||||
}
|
Components.interfaces.nsIJunkMailPlugin.IS_HAM_SCORE);
|
||||||
return;
|
db.setStringProperty(aMsgHdr.messageKey, "junkscoreorigin", "whitelist");
|
||||||
|
this.mGoodMsgHdrs.appendElement(aMsgHdr, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,12 +361,15 @@ function processFolderForJunk(aAll)
|
||||||
var tmpMsgHdr = messenger.messageServiceFromURI(tmpMsgURI).messageURIToMsgHdr(tmpMsgURI);
|
var tmpMsgHdr = messenger.messageServiceFromURI(tmpMsgURI).messageURIToMsgHdr(tmpMsgURI);
|
||||||
var spamSettings = tmpMsgHdr.folder.server.spamSettings;
|
var spamSettings = tmpMsgHdr.folder.server.spamSettings;
|
||||||
|
|
||||||
// if enabled in the spam settings, retrieve whitelist addressbook
|
// if enabled in the spam settings, retrieve whitelist addressbooks
|
||||||
var whiteListDirectory = null;
|
var whiteListDirectories = [];
|
||||||
if (spamSettings.useWhiteList && spamSettings.whiteListAbURI) {
|
if (spamSettings.useWhiteList && spamSettings.whiteListAbURI)
|
||||||
whiteListDirectory = Components.classes["@mozilla.org/abmanager;1"]
|
{
|
||||||
.getService(Components.interfaces.nsIAbManager)
|
var whiteListAbURIs = spamSettings.whiteListAbURI.split(" ");
|
||||||
.getDirectory(spamSettings.whiteListAbURI);
|
abManager = Components.classes["@mozilla.org/abmanager;1"]
|
||||||
|
.getService(Components.interfaces.nsIAbManager);
|
||||||
|
for (var abCount = 0; abCount < whiteListAbURIs.length; abCount++)
|
||||||
|
whiteListDirectories.push(abManager.getDirectory(whiteListAbURIs[abCount]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a classifier instance to classify messages in the folder.
|
// create a classifier instance to classify messages in the folder.
|
||||||
|
@ -378,7 +382,7 @@ function processFolderForJunk(aAll)
|
||||||
{
|
{
|
||||||
var msgURI = gDBView.getURIForViewIndex(index);
|
var msgURI = gDBView.getURIForViewIndex(index);
|
||||||
var msgHdr = messenger.messageServiceFromURI(msgURI).messageURIToMsgHdr(msgURI);
|
var msgHdr = messenger.messageServiceFromURI(msgURI).messageURIToMsgHdr(msgURI);
|
||||||
msgClassifier.analyzeMessage(msgHdr, whiteListDirectory);
|
msgClassifier.analyzeMessage(msgHdr, whiteListDirectories);
|
||||||
}
|
}
|
||||||
catch (ex)
|
catch (ex)
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче