This is an automated email from the ASF dual-hosted git repository. humbedooh pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit 9970cebcf10be783f51b2828e3420dc7b5100b32 Author: Daniel Gruno <[email protected]> AuthorDate: Wed Nov 10 21:55:25 2021 +0100 Add to/cc extras as a key/value pair in plain rendering. This fixes #123 by adding a CC field that includes everything but the list in the vetn that more than the list was sent to or CC'ed. --- webui/js/ponymail.js | 36 ++++++++++++++++++++++++++++++++++++ webui/js/source/render-email.js | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/webui/js/ponymail.js b/webui/js/ponymail.js index 959063f..ec7e8a1 100644 --- a/webui/js/ponymail.js +++ b/webui/js/ponymail.js @@ -3456,6 +3456,22 @@ function unshortenID(mid) { let full_emails = {}; +// Function for parsing email addresses from a to or cc line +function get_rcpts(addresses) { + let list_of_emails = [] + for (let a of addresses.split(/,\s*/)) { + let m = a.match(/<(.+)>/); + if (m) { + a = m[1]; + } + if (a && a.length > 5) { // more than [email protected] + list_of_emails.push(a); + console.log(a); + } + } + return list_of_emails; +} + async function render_email(state, json) { let div = state.div; full_emails[json.mid] = json; // Save for composer if replying later... @@ -3530,6 +3546,26 @@ async function render_email(state, json) { list_field.inject([list_key, list_value]); div.inject(list_field); + // To + CC if need be + let rcpts = get_rcpts(json.to); + rcpts.push(...get_rcpts(json.cc)); + rcpts.remove(listname); + if (rcpts.length) { + let rcpt_field = new HTML('div', { + class: 'email_kv' + }); + let rcpt_key = new HTML('div', { + class: 'email_key' + }, "CC: "); + let rcpt_value = new HTML('div', { + class: 'email_value' + }, + new HTML('span', {}, rcpts.join(", ")) + ); + rcpt_field.inject([rcpt_key, rcpt_value]); + div.inject(rcpt_field); + } + // Private email?? if (json.private === true) { let priv_field = new HTML('div', { diff --git a/webui/js/source/render-email.js b/webui/js/source/render-email.js index 4bb6c7d..6d1b2ef 100644 --- a/webui/js/source/render-email.js +++ b/webui/js/source/render-email.js @@ -1,5 +1,21 @@ let full_emails = {}; +// Function for parsing email addresses from a to or cc line +function get_rcpts(addresses) { + let list_of_emails = [] + for (let a of addresses.split(/,\s*/)) { + let m = a.match(/<(.+)>/); + if (m) { + a = m[1]; + } + if (a && a.length > 5) { // more than [email protected] + list_of_emails.push(a); + console.log(a); + } + } + return list_of_emails; +} + async function render_email(state, json) { let div = state.div; full_emails[json.mid] = json; // Save for composer if replying later... @@ -74,6 +90,26 @@ async function render_email(state, json) { list_field.inject([list_key, list_value]); div.inject(list_field); + // To + CC if need be + let rcpts = get_rcpts(json.to); + rcpts.push(...get_rcpts(json.cc)); + rcpts.remove(listname); + if (rcpts.length) { + let rcpt_field = new HTML('div', { + class: 'email_kv' + }); + let rcpt_key = new HTML('div', { + class: 'email_key' + }, "CC: "); + let rcpt_value = new HTML('div', { + class: 'email_value' + }, + new HTML('span', {}, rcpts.join(", ")) + ); + rcpt_field.inject([rcpt_key, rcpt_value]); + div.inject(rcpt_field); + } + // Private email?? if (json.private === true) { let priv_field = new HTML('div', {
