-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2345cf
commit 5d16331
Showing
2 changed files
with
64 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2019-2022 Michael Pozhidaev <[email protected]> | ||
Copyright 2019-2024 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
@@ -14,6 +14,36 @@ | |
General Public License for more details. | ||
*/ | ||
|
||
const PROPERTY_MAILING_LIST = "mailing-list"; | ||
|
||
Luwrain.addHook("luwrain.mail.incoming", (mail, msg) => { | ||
var folder = null; | ||
const headers = msg.getHeader("List-Id"); | ||
if (headers.length > 0) { | ||
var listId = headers[0] | ||
var personal = mail.getAddressPersonalName(listId); | ||
if (!personal) { | ||
const from= msg.getHeader("From"); | ||
if (from.length > 0) | ||
personal = mail.getAddressPersonalName(from[0]); | ||
} | ||
listId = mail.getAddressWithoutPersonalName(listId); | ||
if (!personal) | ||
personal = listId; | ||
folder = mail.getFolders().findFirstByProperty(PROPERTY_MAILING_LIST, listId); | ||
if (!folder) { | ||
folder = mail.getFolders().getDefaultMailingLists().newSubfolder(); | ||
folder.setName(personal); | ||
folder.getProperties().setProperty(PROPERTY_MAILING_LIST, listId); | ||
folder.update(); | ||
} | ||
} else | ||
folder = mail.getFolders().getDefaultIncoming(); | ||
if (!folder) | ||
throw "No folder to save the mail"; | ||
folder.saveMessage(msg); | ||
}); | ||
|
||
Luwrain.addHook("luwrain.pim.mail.save.new", function(mail, message){ | ||
const defaultIncoming = mail.getFolders().findByProp("defaultIncoming", "true") | ||
if (!defaultIncoming) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters