-
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.
Renaming core-mail-summary.js to core-mail.js
- Loading branch information
1 parent
5d16331
commit 2541bf8
Showing
2 changed files
with
32 additions
and
87 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,35 @@ | |
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.mail.summary", (mail, messages)=>{ | ||
const topics = []; | ||
|
@@ -62,3 +91,5 @@ Luwrain.addHook("luwrain.mail.reply", (message)=>{ | |
Luwrain.launchApp("message", [JSON.stringify(arg)]); | ||
return true; | ||
}); | ||
|
||
|