Skip to content

Commit

Permalink
Renaming core-mail-summary.js to core-mail.js
Browse files Browse the repository at this point in the history
  • Loading branch information
marigostra committed May 6, 2024
1 parent 5d16331 commit 2541bf8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 87 deletions.
86 changes: 0 additions & 86 deletions js/core-mail-incoming.js

This file was deleted.

33 changes: 32 additions & 1 deletion js/core-mail-summary.js → js/core-mail.js
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.
Expand All @@ -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 = [];
Expand Down Expand Up @@ -62,3 +91,5 @@ Luwrain.addHook("luwrain.mail.reply", (message)=>{
Luwrain.launchApp("message", [JSON.stringify(arg)]);
return true;
});


0 comments on commit 2541bf8

Please sign in to comment.