a lot of usenet updates
- webtv can post attachments - webtv signatures - TODO: user control disable rendering of post signatures - TODO: as above but for mail too
This commit is contained in:
@@ -52,7 +52,7 @@ else {
|
||||
if (session_data.isRegistered()) {
|
||||
// check for SMTP Password
|
||||
if (session_data.getSessionData("subscriber_smtp_password") === null) {
|
||||
session_data.setUserSMTPPassword(session_data.generatePassword(16));
|
||||
session_data.setUserSMTPPassword(wtvshared.generatePassword(16));
|
||||
}
|
||||
if (session_data.user_id == 0) {
|
||||
var accounts = session_data.listPrimaryAccountUsers();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var message_snapshot_data = null;
|
||||
var message_voicemail_data = null;
|
||||
|
||||
var intro_seen = session_data.mailstore.checkMailIntroSeen();
|
||||
if (!intro_seen && !request_headers.query.intro_seen) {
|
||||
// user is trying to bypass the intro screen
|
||||
@@ -19,29 +19,34 @@ if (!intro_seen && !request_headers.query.intro_seen) {
|
||||
return "200 OK\nwtv-visit: " + clientErrorMsg;
|
||||
}
|
||||
|
||||
if (request_headers.query.clear == "true") {
|
||||
session_data.deleteSessionData("mail_draft");
|
||||
session_data.deleteSessionData("mail_draft_attachments");
|
||||
headers = `300 OK
|
||||
wtv-expire: wtv-mail:/listmail
|
||||
wtv-expire: wtv-mail:/sendmail
|
||||
Location: wtv-mail:/sendmail`;
|
||||
}
|
||||
|
||||
var newsgroup = null;
|
||||
if (wtvshared.parseBool(request_headers.query.discuss)) {
|
||||
newsgroup = request_headers.query.group || request_headers.query.message_to || null;
|
||||
}
|
||||
|
||||
var gourl = "wtv-mail:/sendmail";
|
||||
|
||||
if (newsgroup !== null) {
|
||||
var to_addr = newsgroup;
|
||||
var pageTitle = "Post to " + newsgroup;
|
||||
var article = request_headers.query.article || null;
|
||||
var gourl = gourl + "?group=" + newsgroup;
|
||||
} else {
|
||||
var to_addr = request_headers.query.message_to || null;
|
||||
var pageTitle = "Write an e-mail message"
|
||||
}
|
||||
|
||||
if (request_headers.query.clear == "true") {
|
||||
session_data.deleteSessionData("usenet_draft");
|
||||
session_data.deleteSessionData("usenet_draft_attachments");
|
||||
session_data.deleteSessionData("mail_draft");
|
||||
session_data.deleteSessionData("mail_draft_attachments");
|
||||
headers = `300 OK
|
||||
wtv-expire: wtv-mail:/listmail
|
||||
wtv-expire: wtv-mail:/sendmail
|
||||
${gourl}`;
|
||||
}
|
||||
|
||||
var msg_subject = request_headers.query.message_subject || null;
|
||||
var msg_body = request_headers.query.message_body || null;
|
||||
var to_name = request_headers.query.whatever_webtv_sends_this_as || null;
|
||||
@@ -69,10 +74,11 @@ Location: wtv-mail:/sendmail`;
|
||||
mail_draft_attachments = session_data.getSessionData("usenet_draft_attachments") || {};
|
||||
if (mail_draft_data && !wtvshared.parseBool(request_headers.query.discuss)) {
|
||||
session_data.deleteSessionData("usenet_draft");
|
||||
if (mail_draft_data.to_addr) to_addr = request_headers.query.message_to || mail_draft_data.to_addr;
|
||||
if (mail_draft_data.msg_subject) msg_subject = request_headers.query.message_subject || mail_draft_data.msg_subject;
|
||||
if (mail_draft_data.msg_body) msg_body = request_headers.query.message_body || mail_draft_data.msg_body;
|
||||
if (mail_draft_data.no_signature) no_signature = mail_draft_data.no_signature;
|
||||
if (mail_draft_data.msg_url) newsgroup = newsgroup || mail_draft_data.msg_url;
|
||||
if (mail_draft_data.article) article = article || mail_draft_data.article;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,62 +121,114 @@ Content-Type: audio/wav`;
|
||||
|
||||
|
||||
if (message_snapshot_data) {
|
||||
if (typeof message_snapshot_data == "object") {
|
||||
attachments.push({ 'Content-Type': 'image/jpeg', data: new Buffer.from(message_snapshot_data).toString('base64') });
|
||||
} else {
|
||||
attachments.push({ 'Content-Type': 'image/jpeg', data: message_snapshot_data });
|
||||
var attachment = {
|
||||
'Content-Type': 'image/jpeg',
|
||||
'filename': 'snapshot.jpg'
|
||||
}
|
||||
if (typeof message_snapshot_data == "object") {
|
||||
attachment.data = new Buffer.from(message_snapshot_data).toString('base64');
|
||||
attachment.is_base64 = true;
|
||||
} else
|
||||
attachment.data = message_snapshot_data;
|
||||
|
||||
attachments.push(attachment);
|
||||
}
|
||||
|
||||
if (message_voicemail_data) {
|
||||
if (typeof message_voicemail_data == "object") {
|
||||
attachments.push({ 'Content-Type': 'audio/wav', data: new Buffer.from(message_voicemail_data).toString('base64') });
|
||||
} else {
|
||||
attachments.push({ 'Content-Type': 'audio/wav', data: new message_voicemail_data });
|
||||
var attachment = {
|
||||
'Content-Type': 'audio/wav',
|
||||
'filename': 'voicemail.wav'
|
||||
}
|
||||
|
||||
if (typeof message_voicemail_data == "object") {
|
||||
attachment.data = new Buffer.from(message_voicemail_data).toString('base64');
|
||||
attachment.is_base64 = true;
|
||||
} else
|
||||
attachment.data = message_voicemail_data;
|
||||
|
||||
attachments.push(attachment);
|
||||
}
|
||||
if (newsgroup !== null) {
|
||||
|
||||
if (newsgroup !== null) {
|
||||
var request_is_async = true;
|
||||
if (msg_body === null) {
|
||||
headers = doClientError("Please type a message to send to the group.");
|
||||
sendToClient(socket, headers, '');
|
||||
} else {
|
||||
var local_service_name = request_headers.query['discuss-prefix'] || "wtv-news"
|
||||
const wtvnews = new WTVNews(minisrv_config, local_service_name);
|
||||
var service_config = minisrv_config.services[local_service_name];
|
||||
if (wtvnewsserver) {
|
||||
var tls_path = this.wtvshared.getAbsolutePath(this.minisrv_config.config.ServiceDeps + '/wtv-news');
|
||||
var tls_options = {
|
||||
ca: this.fs.readFileSync(tls_path + '/localserver_ca.pem'),
|
||||
key: this.fs.readFileSync(tls_path + '/localserver_key.pem'),
|
||||
cert: this.fs.readFileSync(tls_path + '/localserver_cert.pem'),
|
||||
checkServerIdentity: () => { return null; }
|
||||
}
|
||||
if (wtvnewsserver.username)
|
||||
wtvnews.initializeUsenet("127.0.0.1", service_config.local_nntp_port, tls_options, wtvnewsserver.username, wtvnewsserver.password);
|
||||
else
|
||||
wtvnews.initializeUsenet("127.0.0.1", service_config.local_nntp_port, tls_options);
|
||||
} else {
|
||||
if (service_config.upstream_auth)
|
||||
wtvnews.initializeUsenet(service_config.upstream_address, service_config.upstream_port, service_config.upstream_tls || null, service_config.upstream_auth.username || null, service_config.upstream_auth.password || null);
|
||||
else
|
||||
wtvnews.initializeUsenet(service_config.upstream_address, service_configupstream_port, service_config.upstream_tls || null);
|
||||
var local_service_name = request_headers.query['discuss-prefix'] || "wtv-news"
|
||||
const wtvnews = new WTVNews(minisrv_config, local_service_name);
|
||||
var service_config = minisrv_config.services[local_service_name];
|
||||
if (wtvnewsserver) {
|
||||
var tls_path = this.wtvshared.getAbsolutePath(this.minisrv_config.config.ServiceDeps + '/wtv-news');
|
||||
var tls_options = {
|
||||
ca: this.fs.readFileSync(tls_path + '/localserver_ca.pem'),
|
||||
key: this.fs.readFileSync(tls_path + '/localserver_key.pem'),
|
||||
cert: this.fs.readFileSync(tls_path + '/localserver_cert.pem'),
|
||||
checkServerIdentity: () => { return null; }
|
||||
}
|
||||
from_addr = userdisplayname + " <" + from_addr + ">";
|
||||
wtvnews.postToGroup(newsgroup, from_addr, msg_subject, msg_body, article).then(() => {
|
||||
session_data.deleteSessionData("usenet_draft");
|
||||
session_data.deleteSessionData("usenet_draft_attachments");
|
||||
headers = `300 OK
|
||||
if (wtvnewsserver.username)
|
||||
wtvnews.initializeUsenet("127.0.0.1", service_config.local_nntp_port, tls_options, wtvnewsserver.username, wtvnewsserver.password);
|
||||
else
|
||||
wtvnews.initializeUsenet("127.0.0.1", service_config.local_nntp_port, tls_options);
|
||||
} else {
|
||||
if (service_config.upstream_auth)
|
||||
wtvnews.initializeUsenet(service_config.upstream_address, service_config.upstream_port, service_config.upstream_tls || null, service_config.upstream_auth.username || null, service_config.upstream_auth.password || null);
|
||||
else
|
||||
wtvnews.initializeUsenet(service_config.upstream_address, service_configupstream_port, service_config.upstream_tls || null);
|
||||
}
|
||||
from_addr = userdisplayname + " <" + from_addr + ">";
|
||||
news_headers = null;
|
||||
if (signature && signature != "" && !no_signature) {
|
||||
var signature_tuple = null;
|
||||
if (signature.indexOf('<html>') >= 0) {
|
||||
attachments.push({
|
||||
"Content-Type": 'text/html',
|
||||
"data": signature,
|
||||
"use_base64": false,
|
||||
"filename": "wtv_signature.html"
|
||||
});
|
||||
} else {
|
||||
if (msg_body) msg_body += "\n" + signature;
|
||||
else msg_body = signature;
|
||||
}
|
||||
}
|
||||
|
||||
if (attachments.length > 0) {
|
||||
// usenet attachments
|
||||
var tuples = [{
|
||||
"mime": 'text/plain',
|
||||
"content": msg_body || '',
|
||||
"use_base64": false
|
||||
}];
|
||||
if (signature_tuple) tuples.push(signature_tuple);
|
||||
attachments.forEach((attachment) => {
|
||||
var tuple = {};
|
||||
tuple.mime = attachment['Content-Type'];
|
||||
tuple.content = attachment.data;
|
||||
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.filename = attachment.filename || null;
|
||||
tuples.push(tuple);
|
||||
});
|
||||
var multipart_data = wtvmime.generateMultipartMIME(tuples);
|
||||
news_headers = {
|
||||
"Content-Type": multipart_data.content_type,
|
||||
"MIME-Version": multipart_data.mime_version,
|
||||
"User-Agent": minisrv_version_string + " for WebTV",
|
||||
"Content-Language": "en-US"
|
||||
}
|
||||
msg_body = multipart_data.content.toString();
|
||||
}
|
||||
wtvnews.postToGroup(newsgroup, from_addr, msg_subject, msg_body, article, news_headers).then(() => {
|
||||
session_data.deleteSessionData("usenet_draft");
|
||||
session_data.deleteSessionData("usenet_draft_attachments");
|
||||
headers = `300 OK
|
||||
wtv-expire: wtv-news:/news?group=${newsgroup}
|
||||
wtv-expire: wtv-mail:/sendmail
|
||||
Location: wtv-news:/news?group=${newsgroup}`;
|
||||
sendToClient(socket, headers, '');
|
||||
}).catch((e) => {
|
||||
var err = this.wtvshared.doErrorPage(500,null,e.toString())
|
||||
sendToClient(socket, err[0], err[1]);
|
||||
});
|
||||
sendToClient(socket, headers, '');
|
||||
}).catch((e) => {
|
||||
var err = this.wtvshared.doErrorPage(500, null, e.toString())
|
||||
sendToClient(socket, err[0], err[1]);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
var messagereturn = session_data.mailstore.sendMessageToAddr(from_addr, to_addr, msg_body, msg_subject, userdisplayname, to_name, signature, attachments, msg_url, msg_url_title);
|
||||
if (messagereturn !== true) {
|
||||
@@ -195,10 +253,9 @@ Location: wtv-mail:/listmail`;
|
||||
no_signature: no_signature,
|
||||
msg_url: msg_url,
|
||||
msg_url_title: msg_url_title,
|
||||
newsgroup: newsgroup,
|
||||
article: article
|
||||
}
|
||||
session_data.setSessionData("mail_draft", mail_draft_data);
|
||||
if (newsgroup) mail_draft_data.article = article;
|
||||
session_data.setSessionData((newsgroup) ? "usenet_draft" : "mail_draft", mail_draft_data);
|
||||
headers = `200 OK
|
||||
Content-type: text/html
|
||||
wtv-expire: wtv-mail:/sendmail`;
|
||||
@@ -207,27 +264,27 @@ wtv-expire: wtv-mail:/sendmail`;
|
||||
|
||||
headers = `200 OK
|
||||
Content-type: text/html`;
|
||||
var mail_draft_data = session_data.getSessionData("mail_draft_attachments") || {};
|
||||
var mail_draft_data = session_data.getSessionData((newsgroup) ? "usenet_draft_attachments" : "mail_draft_attachments") || {};
|
||||
if (request_headers.query.snapping == "false") {
|
||||
headers += "\nwtv-expire: cache:snapshot.jpg";
|
||||
if (mail_draft_data.message_snapshot_data) mail_draft_data.message_snapshot_data = null;
|
||||
session_data.setSessionData("mail_draft_attachments", mail_draft_data);
|
||||
session_data.setSessionData((newsgroup) ? "usenet_draft_attachments" : "mail_draft_attachments", mail_draft_data);
|
||||
}
|
||||
|
||||
if (request_headers.query.gabbing == "false") {
|
||||
headers += "\nwtv-expire: cache:voicemail.wav";
|
||||
if (mail_draft_data.message_voicemail_data) mail_draft_data.message_voicemail_data = null;
|
||||
session_data.setSessionData("mail_draft_attachments", mail_draft_data);
|
||||
session_data.setSessionData((newsgroup) ? "usenet_draft_attachments" : "mail_draft_attachments", mail_draft_data);
|
||||
}
|
||||
|
||||
if (request_headers.query.message_snapshot_data) {
|
||||
mail_draft_data.message_snapshot_data = request_headers.query.message_snapshot_data
|
||||
session_data.setSessionData("mail_draft_attachments", mail_draft_data);
|
||||
session_data.setSessionData((newsgroup) ? "usenet_draft_attachments" : "mail_draft_attachments", mail_draft_data);
|
||||
}
|
||||
|
||||
if (request_headers.query.message_voicemail_data) {
|
||||
mail_draft_data.message_voicemail_data = request_headers.query.message_voicemail_data
|
||||
session_data.setSessionData("mail_draft_attachments", mail_draft_data);
|
||||
session_data.setSessionData((newsgroup) ? "usenet_draft_attachments" : "mail_draft_attachments", mail_draft_data);
|
||||
}
|
||||
var message_colors = null;
|
||||
if (no_signature) message_colors = session_data.mailstore.getSignatureColors(null, true);
|
||||
@@ -276,7 +333,7 @@ ${pageTitle}
|
||||
<input type=hidden name="message_reply_all_cc" value="">
|
||||
${(request_headers.query.article) ? `<input type="hidden" name="article" value="${request_headers.query.article}">` : ''}
|
||||
<input type=hidden name="saveoff" value="true" autosubmit="onleave">
|
||||
<input type=hidden name="discuss" value="${request_headers.query.discuss ? true : false}">
|
||||
<input type=hidden name="discuss" value="${wtvshared.parseBool(request_headers.query.discuss)}">
|
||||
<sidebar width=109>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
@@ -609,7 +666,7 @@ USESTYLE NOARGS>
|
||||
data += `
|
||||
</td></tr><tr>
|
||||
<td colspan="2" align="center">
|
||||
<img src="${(mail_draft_attachments.message_snapshot_data) ? 'wtv-mail:/sendmail?get_snap=true' : 'cache:snapshot.jpg'}" width="380" height="290">
|
||||
<img src="${(mail_draft_attachments.message_snapshot_data) ? 'wtv-mail:/sendmail?get_snap=true' : (request_headers.query.message_snapshot_url) ? request_headers.query.message_snapshot_url : 'cache:snapshot.jpg'}" width="380" height="290">
|
||||
</td></tr><tr>
|
||||
<td colspan="2" abswidth="386" absheight="10">
|
||||
</td></tr><tr>
|
||||
|
||||
@@ -37,7 +37,7 @@ data = `<HTML>
|
||||
<tr>
|
||||
<td abswidth=6 >
|
||||
<td abswidth=93 absheight=26 >
|
||||
<table href="wtv-news:news?category=1"
|
||||
<table href="wtv-news:/news?category=1"
|
||||
cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td abswidth=5>
|
||||
@@ -147,7 +147,7 @@ data += `
|
||||
<td abswidth=416 valign=top align=left>
|
||||
Type a discussion topic<br>
|
||||
<img src="/ROMCache/Spacer.gif" width=1 height=4>
|
||||
<form action="wtv-news:search">
|
||||
<form action="wtv-news:/news" method="GET">
|
||||
<input name="search" bgcolor=#202020 cursor=#cc9933 text="E7CE4A" font=proportional value="" SIZE=28 MAXLENGTH=100>
|
||||
|
||||
<font color=E7CE4A><shadow>
|
||||
|
||||
@@ -90,6 +90,30 @@ top.location="news:${request_headers.query.group}";
|
||||
<tr>
|
||||
<td abswidth=6 >
|
||||
<td abswidth=93 absheight=26 >
|
||||
<table href="wtv-news:/lobby"
|
||||
cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td abswidth=5>
|
||||
<td abswidth=90 valign=middle align=left>
|
||||
<table bgcolor=3d2f3a cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td absheight=1>
|
||||
<tr>
|
||||
<td maxlines=1>
|
||||
<shadow><font sizerange=medium color="E7CE4A">Lobby</font></shadow></table>
|
||||
</table>
|
||||
<td abswidth=5>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=middle align=center bgcolor=231d22>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=1 valign=top align=left <img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=top align=left bgcolor=5b4b58>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td abswidth=6 >
|
||||
<td abswidth=93 absheight=26 >
|
||||
<table href="wtv-mail:/sendmail?discuss=true&group=${request_headers.query.group}&discuss-prefix=${service_name}"
|
||||
cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
@@ -136,7 +160,7 @@ cellspacing=0 cellpadding=0>
|
||||
<td colspan=3 absheight=2 valign=top align=left bgcolor=5b4b58>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 height=237 valign=bottom align=right >
|
||||
<td colspan=3 height=207 valign=bottom align=right >
|
||||
<img src="wtv-news:/images/BannerDiscuss.gif" width=50 height=165> <tr><td colspan=3 absheight=36>
|
||||
</table>
|
||||
</sidebar>
|
||||
@@ -270,11 +294,23 @@ ${(message.headers.FROM.indexOf(' ') > 0) ? message.headers.FROM.split(' ')[0] :
|
||||
</HTML>`;
|
||||
|
||||
sendToClient(socket, headers, data);
|
||||
}).catch((e) => { throwError(e) });;
|
||||
}).catch((e) => {
|
||||
// getHeaderObj err
|
||||
throwError(e)
|
||||
});;
|
||||
}
|
||||
}).catch((e) => { throwError(e) });;
|
||||
}).catch((e) => { throwError(e) });;
|
||||
}).catch((e) => { throwError(e) });
|
||||
}).catch((e) => {
|
||||
// listGroup error
|
||||
throwError(e)
|
||||
});;
|
||||
}).catch((e) => {
|
||||
// selectGroup error
|
||||
throwError(e)
|
||||
});
|
||||
}).catch((e) => {
|
||||
// connect error
|
||||
throwError(e)
|
||||
});
|
||||
}
|
||||
|
||||
async function WebTVShowMessage(group, article) {
|
||||
@@ -283,13 +319,30 @@ async function WebTVShowMessage(group, article) {
|
||||
wtvnews.selectGroup(group).then((response) => {
|
||||
wtvnews.getArticle(article).then((response) => {
|
||||
wtvnews.quitUsenet();
|
||||
if (response.code == 220) {
|
||||
headers = `200 OK
|
||||
headers = `200 OK
|
||||
Content-type: text/html
|
||||
wtv-expire-all: wtv-news:/news?group=${group}&article=`;
|
||||
var message_colors = session_data.mailstore.defaultColors;
|
||||
var signature = null;
|
||||
var message_colors = session_data.mailstore.defaultColors;
|
||||
var display_signature = true; // todo make a toggle
|
||||
var message = wtvnews.parseAttachments(response);
|
||||
var message_body = message.text;
|
||||
var attachments = null;
|
||||
var signature_index = null;
|
||||
if (message.attachments) attachments = message.attachments;
|
||||
Object.keys(attachments).forEach((k) => {
|
||||
if (attachments[k].filename == "wtv_signature.html" && attachments[k].content_type.match(/text\/html/)) {
|
||||
signature = attachments[k].data;
|
||||
signature_index = k;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
attachments.splice(signature_index, 1);
|
||||
console.log(signature)
|
||||
|
||||
data = `<head>
|
||||
if (signature) message_colors = session_data.mailstore.getSignatureColors(signature);
|
||||
|
||||
data = `<head>
|
||||
<sendpanel
|
||||
action="wtv-mail:/sendmail?message_forward_id=1&mailbox_name=inbox"
|
||||
message="Forward this post to someone else."
|
||||
@@ -525,13 +578,13 @@ ${strftime("%a, %b %e, %Y, %I:%M%P", new Date(Date.parse(response.article.header
|
||||
<td valign=top>
|
||||
From:
|
||||
<td>`;
|
||||
// if (message.from_name != message.from_addr) {
|
||||
// data += `<a href="client:showalert?sound=none&message=Would%20you%20like%20to%20add%20%3Cblackface%3E${wtvshared.htmlEntitize(message.from_name)}%3C%2Fblackface%3E%20to%20your%20address%20list%3F&buttonlabel2=No&buttonaction2=client:donothing&buttonlabel1=Yes&buttonaction1=wtv-mail:/addressbook%3Faction%3Deditfromheader%26noresponse%3Dtrue%26nickname%3D${escape(escape(message.from_name))}%26address%3D${escape(escape(message.from_addr))}%26new_address%3Dtrue">${wtvshared.htmlEntitize(message.from_addr)} </a>`;
|
||||
// } else {
|
||||
data += `${wtvshared.htmlEntitize(response.article.headers.FROM)}`;
|
||||
// }
|
||||
// if (message.from_name != message.from_addr) {
|
||||
// data += `<a href="client:showalert?sound=none&message=Would%20you%20like%20to%20add%20%3Cblackface%3E${wtvshared.htmlEntitize(message.from_name)}%3C%2Fblackface%3E%20to%20your%20address%20list%3F&buttonlabel2=No&buttonaction2=client:donothing&buttonlabel1=Yes&buttonaction1=wtv-mail:/addressbook%3Faction%3Deditfromheader%26noresponse%3Dtrue%26nickname%3D${escape(escape(message.from_name))}%26address%3D${escape(escape(message.from_addr))}%26new_address%3Dtrue">${wtvshared.htmlEntitize(message.from_addr)} </a>`;
|
||||
// } else {
|
||||
data += `${wtvshared.htmlEntitize(response.article.headers.FROM)}`;
|
||||
// }
|
||||
|
||||
data += `<tr>
|
||||
data += `<tr>
|
||||
<td nowrap valign=top>
|
||||
<td>
|
||||
</table>
|
||||
@@ -544,68 +597,259 @@ ${(response.article.headers.SUBJECT) ? wtvshared.htmlEntitize(response.article.h
|
||||
<td abswidth=20 rowspan=99>
|
||||
<tr>
|
||||
<td>
|
||||
`;
|
||||
var message = wtvnews.parseAttachments(response);
|
||||
var message_body = message.text;
|
||||
var attachments = null;
|
||||
if (message.attachments) attachments = message.attachments;
|
||||
data += `
|
||||
`
|
||||
data += `
|
||||
${wtvshared.htmlEntitize(message_body, true)}
|
||||
<br>
|
||||
<br>`;
|
||||
data += "<p>";
|
||||
|
||||
if (attachments) {
|
||||
var supported_images = /image\/(jpe?g|png|gif|x-wtv-bitmap)/;
|
||||
var supported_audio = /audio\/(mp[eg|2|3]|midi?|wav|x-wav|mod|x-mod)/;
|
||||
attachments.forEach((v, k) => {
|
||||
if (v.content_type) {
|
||||
if (v.content_type.match(supported_images))
|
||||
data += `<img border=2 src="wtv-news:/get-attachment?group=${group}&article=${article}&attachment_id=${k}&wtv-title=Video%20Snapshot"><br><br>`;
|
||||
else if (v.content_type.match(supported_audio))
|
||||
data += `<table href="wtv-news:/get-attachment?group=${group}&article=${article}&attachment_id=${k}&wtv-title=${(v.filename) ? encodeURIComponent(v.filename) : "Audio%20file"}" width=386 cellspacing=0 cellpadding=0>
|
||||
if (signature) data += wtvshared.sanitizeSignature(signature);
|
||||
data += "<p>";
|
||||
|
||||
if (attachments) {
|
||||
var supported_images = /image\/(jpe?g|png|gif|x-wtv-bitmap)/;
|
||||
var supported_audio = /audio\/(mp[eg|2|3]|midi?|wav|x-wav|mod|x-mod)/;
|
||||
attachments.forEach((v, k) => {
|
||||
if (v.content_type) {
|
||||
if (v.content_type.match(supported_images))
|
||||
data += `<img border=2 src="wtv-news:/get-attachment?group=${group}&article=${article}&attachment_id=${k}&wtv-title=Video%20Snapshot"><br><br>`;
|
||||
else if (v.content_type.match(supported_audio))
|
||||
data += `<table href="wtv-news:/get-attachment?group=${group}&article=${article}&attachment_id=${k}&wtv-title=${(v.filename) ? encodeURIComponent(v.filename) : "Audio%20file"}" width=386 cellspacing=0 cellpadding=0>
|
||||
<td align=left valign=middle><img src="wtv-news:/ROMCache/FileSound.gif" align=absmiddle><font color="#189CD6"> ${(v.filename) ? (v.filename) : "Audio file"} (${v.content_type.split('/')[1]} attachment)</font>
|
||||
<td align=right valign=middle>
|
||||
</table><br><br>`;
|
||||
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>`
|
||||
}
|
||||
});
|
||||
}
|
||||
/*
|
||||
if (message.url) {
|
||||
data += `Included Page: <a href="${(message.url)}">${wtvshared.htmlEntitize(message.url_title).replace(/'/gi, "'")}`;
|
||||
}
|
||||
*/
|
||||
data += "</table></body></html>";
|
||||
sendToClient(socket, headers, data);
|
||||
|
||||
} else {
|
||||
throwError("invalid response code. expected: 220, received:", response.code);
|
||||
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>`
|
||||
}
|
||||
});
|
||||
}
|
||||
/*
|
||||
if (message.url) {
|
||||
data += `Included Page: <a href="${(message.url)}">${wtvshared.htmlEntitize(message.url_title).replace(/'/gi, "'")}`;
|
||||
}
|
||||
*/
|
||||
data += "</table></body></html>";
|
||||
sendToClient(socket, headers, data);
|
||||
|
||||
}).catch((e) => {
|
||||
throwError(e);
|
||||
// no such article
|
||||
var post_unavailable_file = this.wtvshared.getAbsolutePath(this.minisrv_config.config.ServiceDeps + '/wtv-news/post-unavailable.html');
|
||||
if (fs.existsSync(post_unavailable_file)) {
|
||||
headers = "200 OK\nContent-type: text/html";
|
||||
data = fs.readFileSync(post_unavailable_file).toString('ascii').replace("${group}", group).replace("${minisrv_config.config.service_logo}", minisrv_config.config.service_logo).replace("${message_colors.bgcolor}",session_data.mailstore.defaultColors.bgcolor);
|
||||
sendToClient(socket, headers, data);
|
||||
} else {
|
||||
throwError(e);
|
||||
}
|
||||
});
|
||||
}).catch((e) => {
|
||||
// no such group
|
||||
throwError(e);
|
||||
});
|
||||
}).catch((e) => {
|
||||
//no connection
|
||||
throwError(e);
|
||||
});;
|
||||
});
|
||||
}
|
||||
|
||||
function WebTVSearchGroups(search) {
|
||||
console.log('WebTVSearchGroups init')
|
||||
wtvnews.connectUsenet().then(() => {
|
||||
console.log('WebTVSearchGroups connected')
|
||||
wtvnews.listGroups(search).then((response) => {
|
||||
console.log('WebTVSearchGroups listGroups response', response)
|
||||
wtvnews.quitUsenet();
|
||||
headers = `200 OK
|
||||
Content-type: text/html
|
||||
wtv-expire-all: wtv-news:/news?search=`;
|
||||
|
||||
data = `<HTML>
|
||||
<HEAD>
|
||||
<DISPLAY fontsize=medium>
|
||||
<TITLE>${(response.length == 0) ? "No " : ""}Discussion groups found</TITLE>
|
||||
</HEAD>
|
||||
<sidebar width=114 height=420 align=left>
|
||||
<table cellspacing=0 cellpadding=0 bgcolor=3d2f3a>
|
||||
<tr>
|
||||
<td colspan=3 width=104 absheight=4>
|
||||
<td rowspan=100 width=10 height=420 valign=top align=left bgcolor=191919>
|
||||
<img src="wtv-mail:/ROMCache/Shadow.gif" width=6 height=420>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<td abswidth=93 absheight=76>
|
||||
<table href="wtv-home:/home" absheight=76 cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td align=right>
|
||||
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
|
||||
</table>
|
||||
<td abswidth=5>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=middle align=center bgcolor=231d22>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=1 valign=top align=left <img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=top align=left bgcolor=5b4b58>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td abswidth=6 >
|
||||
<td abswidth=93 absheight=26 >
|
||||
<table href="wtv-news:/news?category=1"
|
||||
cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td abswidth=5>
|
||||
<td abswidth=90 valign=middle align=left>
|
||||
<table bgcolor=3d2f3a cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td absheight=1>
|
||||
<tr>
|
||||
<td maxlines=1>
|
||||
<shadow><font sizerange=medium color="E7CE4A">All groups</font></shadow></table>
|
||||
</table>
|
||||
<td abswidth=5>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=middle align=center bgcolor=231d22>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=1 valign=top align=left <img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=top align=left bgcolor=5b4b58>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td abswidth=6 >
|
||||
<td abswidth=93 absheight=26 >
|
||||
<table href="wtv-guide:/help?topic=Discuss&subtopic=Index&appName=Discuss"
|
||||
cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td abswidth=5>
|
||||
<td abswidth=90 valign=middle align=left>
|
||||
<table bgcolor=3d2f3a cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td absheight=1>
|
||||
<tr>
|
||||
<td maxlines=1>
|
||||
<shadow><font sizerange=medium color="E7CE4A">Help</font></shadow></table>
|
||||
</table>
|
||||
<td abswidth=5>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=middle align=center bgcolor=231d22>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=1 valign=top align=left <img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=top align=left bgcolor=5b4b58>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 height=237 valign=bottom align=right >
|
||||
<img src="wtv-news:/images/BannerDiscuss.gif" width=50 height=165>
|
||||
<tr><td colspan=3 absheight=36>
|
||||
</table>
|
||||
</sidebar>
|
||||
<body
|
||||
bgcolor="191919" text="42BD52" link="189CD6"
|
||||
vlink="189CD6"
|
||||
hspace=0
|
||||
vspace=0>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td abswidth=10>
|
||||
<td colspan=3>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td valign=center absheight=80>
|
||||
<font size="+2" color="E7CE4A"><blackface><shadow>
|
||||
${(response.length == 0) ? "No " : ""}Discussion groups found
|
||||
</table>
|
||||
<td abswidth=20>
|
||||
<tr>
|
||||
<td>
|
||||
<td WIDTH=198 HEIGHT=200 VALIGN=top ALIGN=left>`;
|
||||
|
||||
if (response.length == 0) {
|
||||
data += `There are no discussion groups that match your request. Do you want to look for something else?`;
|
||||
} else {
|
||||
response.forEach((group) => {
|
||||
data += `<hr width=436>
|
||||
<IMG src="wtv-home:/ROMCache/Spacer.gif" width=1 height=6><br>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td width=10>
|
||||
<td width=426> <table href="wtv-news:/news?group=${group.name}" selected cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td abswidth=401 height=19 valign=top>
|
||||
<shadow><b>${group.name}</table>
|
||||
<td width=10>
|
||||
|
||||
`
|
||||
if (group.description) {
|
||||
data += `<tr><td colspan=3 width=10 height=6><tr><td width=10><td colspan=99><i><font color=828282>${group.description}</font></i>`
|
||||
}
|
||||
data += "</table>";
|
||||
});
|
||||
}
|
||||
|
||||
data += `
|
||||
</table>
|
||||
<TABLE width=446 cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td rowspan=3 width=10 height=1>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=10 height=1>
|
||||
<td height=2 width=436 bgcolor="2B2B2B">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=436 height=1>
|
||||
<tr>
|
||||
<td height=1>
|
||||
<tr>
|
||||
<td height=2 bgcolor="0D0D0D">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
</TABLE>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td rowspan=2 abswidth=10>
|
||||
<td absheight=10>
|
||||
<tr>
|
||||
<td abswidth=416 valign=top align=left>
|
||||
Do you want to look for something else?<br>
|
||||
<img src="/ROMCache/Spacer.gif" width=1 height=4>
|
||||
<form action="wtv-news:search">
|
||||
<input name="search" bgcolor=#202020 cursor=#cc9933 text="E7CE4A" font=proportional value="" SIZE=28 MAXLENGTH=100>
|
||||
|
||||
<font color=E7CE4A><shadow>
|
||||
<input type=submit borderimage="file://ROM/Borders/ButtonBorder2.bif" value="Look for" usestyle>
|
||||
</shadow></font>
|
||||
</form>
|
||||
</table>
|
||||
</BODY>
|
||||
</HTML>`;
|
||||
sendToClient(socket, headers, data);
|
||||
}).catch((e) => {
|
||||
// listGroups error
|
||||
throwError(e);
|
||||
});
|
||||
|
||||
}).catch((e) => {
|
||||
// no connection
|
||||
throwError(e);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (!wtvnews.client) {
|
||||
var errpage = doErrorPage();
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
} else {
|
||||
var request_is_async = true;
|
||||
if (request_headers.query.group) {
|
||||
if (request_headers.query.search) {
|
||||
WebTVSearchGroups(request_headers.query.search)
|
||||
} else if (request_headers.query.group) {
|
||||
if (request_headers.query.article) {
|
||||
WebTVShowMessage(request_headers.query.group, request_headers.query.article);
|
||||
} else {
|
||||
WebTVListGroup(request_headers.query.group);
|
||||
}
|
||||
} else {
|
||||
// redirect to lobby if no understandable queries passed
|
||||
headers = "300 OK\nLocation: wtv-news:/lobby";
|
||||
sendToClient(socket, headers, null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user