html news post is proper RFC mime attachment

This commit is contained in:
zefie
2022-11-30 14:05:59 -05:00
parent eba56942a1
commit c1ad83b152
2 changed files with 28 additions and 16 deletions

View File

@@ -144,29 +144,29 @@ Content-Type: audio/wav`;
if (message_snapshot_data) { if (message_snapshot_data) {
var attachment = { var attachment = {
'Content-Type': 'image/jpeg', 'mime': 'image/jpeg',
'filename': 'snapshot.jpg' 'filename': 'snapshot.jpg'
} }
if (typeof message_snapshot_data == "object") { if (typeof message_snapshot_data == "object") {
attachment.data = new Buffer.from(message_snapshot_data).toString('base64'); attachment.content = new Buffer.from(message_snapshot_data).toString('base64');
attachment.is_base64 = true; attachment.is_base64 = true;
} else } else
attachment.data = message_snapshot_data; attachment.content = message_snapshot_data;
attachments.push(attachment); attachments.push(attachment);
} }
if (message_voicemail_data) { if (message_voicemail_data) {
var attachment = { var attachment = {
'Content-Type': 'audio/wav', 'mime': 'audio/wav',
'filename': 'voicemail.wav' 'filename': 'voicemail.wav'
} }
if (typeof message_voicemail_data == "object") { if (typeof message_voicemail_data == "object") {
attachment.data = new Buffer.from(message_voicemail_data).toString('base64'); attachment.content = new Buffer.from(message_voicemail_data).toString('base64');
attachment.is_base64 = true; attachment.is_base64 = true;
} else } else
attachment.data = message_voicemail_data; attachment.content = message_voicemail_data;
attachments.push(attachment); attachments.push(attachment);
} }
@@ -199,8 +199,8 @@ Content-Type: audio/wav`;
var signature_tuple = null; var signature_tuple = null;
if (signature.indexOf('<html>') >= 0) { if (signature.indexOf('<html>') >= 0) {
attachments.push({ attachments.push({
"Content-Type": 'text/html', "mime": 'text/html',
"data": signature, "content": signature,
"use_base64": false, "use_base64": false,
"filename": "wtv_signature.html" "filename": "wtv_signature.html"
}); });
@@ -210,18 +210,28 @@ Content-Type: audio/wav`;
} }
} }
if (attachments.length > 0) { if (attachments.length > 0 || msg_body.indexOf('<html>') >= 0) {
// usenet attachments // usenet attachments
var tuples = [{ var tuples = [];
"mime": 'text/plain', if (msg_body.indexOf('<html>') >= 0) {
"content": msg_body || '', tuples.push({
"use_base64": false "mime": 'text/html',
}]; "content": msg_body,
"use_base64": false,
"filename": "message.html"
});
} else {
tuples = [{
"mime": 'text/plain',
"content": msg_body || '',
"use_base64": false
}];
}
if (signature_tuple) tuples.push(signature_tuple); if (signature_tuple) tuples.push(signature_tuple);
attachments.forEach((attachment) => { attachments.forEach((attachment) => {
var tuple = {}; var tuple = {};
tuple.mime = attachment['Content-Type']; tuple.mime = attachment.mime;
tuple.content = attachment.data; tuple.content = attachment.content;
tuple.use_base64 = (typeof attachment.use_base64 === 'boolean') ? attachment.use_base64 : true; tuple.use_base64 = (typeof attachment.use_base64 === 'boolean') ? attachment.use_base64 : true;
tuple.is_base64 = (typeof attachment.is_base64 === 'boolean') ? attachment.is_base64 : false; tuple.is_base64 = (typeof attachment.is_base64 === 'boolean') ? attachment.is_base64 : false;
tuple.filename = attachment.filename || null; tuple.filename = attachment.filename || null;

View File

@@ -638,6 +638,8 @@ From:
<td align=left valign=middle><img src="wtv-news:/ROMCache/FileSound.gif" align=absmiddle><font color="#189CD6">&nbsp;&nbsp;${(v.filename) ? (v.filename) : "Audio file"} (${v.content_type.split('/')[1]} attachment)</font> <td align=left valign=middle><img src="wtv-news:/ROMCache/FileSound.gif" align=absmiddle><font color="#189CD6">&nbsp;&nbsp;${(v.filename) ? (v.filename) : "Audio file"} (${v.content_type.split('/')[1]} attachment)</font>
<td align=right valign=middle> <td align=right valign=middle>
</table><br><br>`; </table><br><br>`;
else if (v.content_type.match("text/html"))
data += wtvshared.sanitizeSignature(v.data);
else else
data += `<table width=386><td><td align=left valign=middle><font color="#565656"><i>A file ${(v.filename) ? `(${v.filename}) ` : ''}that WebTV cannot use, with type ${v.content_type} is attached to this message.</i></font>` data += `<table width=386><td><td align=left valign=middle><font color="#565656"><i>A file ${(v.filename) ? `(${v.filename}) ` : ''}that WebTV cannot use, with type ${v.content_type} is attached to this message.</i></font>`
} }