enable html mail and usenet bodies

- also move subject for usenet
This commit is contained in:
zefie
2022-11-30 13:33:10 -05:00
parent bb60066100
commit 0bdc16b0cb
3 changed files with 40 additions and 10 deletions

View File

@@ -39,7 +39,16 @@ Location: wtv-mail:/listmail`;
headers = `200 OK
Content-type: text/html`;
var message_colors = session_data.mailstore.getSignatureColors(message.signature);
var message_colors = null;
if (message.body.indexOf("<body")) {
var default_colors = session_data.mailstore.defaultColors;
var message_colors = session_data.mailstore.getSignatureColors(message.body);
if (message_colors == default_colors) message_colors = null;
}
if (!message_colors) message_colors = session_data.mailstore.getSignatureColors(message.signature);
if (typeof message.subject == "object" && message.subject) message.subject = wtvshared.decodeBufferText(message.subject);
data = `<wtvnoscript>
@@ -275,7 +284,10 @@ ${(message.subject) ? wtvshared.htmlEntitize(message.subject) : '(No subject)'}
message.body = wtvshared.decodeBufferText(message.body);
}
if (message.body) message.body = message.body.replace(/\n/g, "<br><br>");
data += `${(message.allow_html) ? message.body : wtvshared.htmlEntitize(message.body, true)}
if (message.body.indexOf("<html>") >= 0) {
message.allow_html = true;
}
data += `${(message.allow_html) ? wtvshared.sanitizeSignature(message.body) : wtvshared.htmlEntitize(message.body, true)}
<br>
<br>`;
if (message.signature) {
@@ -283,6 +295,7 @@ ${(message.subject) ? wtvshared.htmlEntitize(message.subject) : '(No subject)'}
}
data += `<p>
`;
console.log(message.body);
console.log(message.allow_html)
if (Array.isArray(message.attachments)) {
message.attachments.forEach((v, k) => {

View File

@@ -347,6 +347,14 @@ wtv-expire-all: wtv-news:/news?group=${group}&article=`;
if (signature_index) attachments.splice(signature_index, 1);
}
}
if (message_body.indexOf("<body")) {
var default_colors = session_data.mailstore.defaultColors;
var message_colors = session_data.mailstore.getSignatureColors(message_body);
if ((message_colors == default_colors) && signature) message_colors = null;
}
if (!message_colors && signature) message_colors = session_data.mailstore.getSignatureColors(signature);
if (signature) message_colors = session_data.mailstore.getSignatureColors(signature);
data = `<head>
@@ -580,7 +588,6 @@ ${wtvshared.htmlEntitize(response.article.headers.NEWSGROUPS)}
<td valign=top>
Date: <td>
${strftime("%a, %b %e, %Y, %I:%M%P", new Date(Date.parse(response.article.headers.DATE)))}
<font size=-1> </font>
<tr>
<td valign=top>
From:
@@ -594,19 +601,26 @@ From:
data += `<tr>
<td nowrap valign=top>
<td>
<tr>
<td valign=top>Subject:
<td>${(response.article.headers.SUBJECT) ? wtvshared.htmlEntitize(response.article.headers.SUBJECT) : '(No subject)'}
</table>
<br><br>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=10 rowspan=99>
<td><br><br><br><font color=E7CE4A>
${(response.article.headers.SUBJECT) ? wtvshared.htmlEntitize(response.article.headers.SUBJECT) : '(No subject)'}<br><br>
</font>
<td abswidth=20 rowspan=99>
<tr>
<td>
`
`;
var allow_html = false;
if (message_body) {
if (message_body.indexOf("<html>") >= 0) {
allow_html = true;
}
}
data += (allow_html) ? wtvshared.sanitizeSignature(message_body) : wtvshared.htmlEntitize(message_body, true)
data += `
${wtvshared.htmlEntitize(message_body, true)}
<br>
<br>`;
if (signature) data += wtvshared.sanitizeSignature(signature);