incomplete NNTP usenet support

This commit is contained in:
zefie
2022-09-25 22:52:18 -04:00
parent d8da9e14c7
commit b2aece5437
11 changed files with 927 additions and 31 deletions

View File

@@ -47,7 +47,8 @@ minisrv v${minisrv_config.version}${(minisrv_config.config.git_commit) ? ' git-'
<li><a href="client:relog">client:relog (direct)</a></li>
<li><a href="wtv-flashrom:/willie" selected>Ultra Willies</a> ~ <a href="wtv-tricks:/tricks">Tricks</a></li>
<li><a href="wtv-setup:/setup">Setup (Including BG Music)</a></li>
<li><a href="${ssid_sessions[socket.ssid].mailstore.checkMailIntroSeen() ? 'wtv-mail:/listmail' : 'wtv-mail:/DiplomaMail'}">Mail (not ready)</a>
<li><a href="${ssid_sessions[socket.ssid].mailstore.checkMailIntroSeen() ? 'wtv-mail:/listmail' : 'wtv-mail:/DiplomaMail'}">Mail (beta)</a>
<li><a href="wtv-news:/lobby">Usenet (not ready)</a>
`;
if (ssid_sessions[socket.ssid].hasCap("client-can-do-chat")) {
data += "<li><a href=\"wtv-chat:/home\">IRC Chat Test</a></li>\n"

View File

@@ -16,7 +16,7 @@ if (!intro_seen && !request_headers.query.intro_seen) {
'noback': true,
}).getURL();
headers = "300 OK\nwtv-visit: " + clientErrorMsg;
headers = "200 OK\nwtv-visit: " + clientErrorMsg;
}
if (request_headers.query.clear == "true") {
@@ -28,8 +28,16 @@ wtv-expire: wtv-mail:/sendmail
Location: wtv-mail:/sendmail`;
}
var newsgroup = null;
if (request_headers.query.discuss) {
newsgroup = request_headers.query.group || request_headers.query.message_to || null;
var to_addr = newsgroup;
var pageTitle = "Post to " + newsgroup;
} else {
var to_addr = request_headers.query.message_to || null;
var pageTitle = "Write an e-mail message"
}
var to_addr = request_headers.query.message_to || null;
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;
@@ -47,6 +55,7 @@ Location: wtv-mail:/sendmail`;
if (mail_draft_data.no_signature) no_signature = mail_draft_data.no_signature;
if (mail_draft_data.msg_url) msg_url = mail_draft_data.msg_url;
if (mail_draft_data.msg_url_title) msg_url_title = mail_draft_data.msg_url_title;
if (mail_draft.data.newsgroup) newsgroup = mail_draft_data.newsgroup;
}
if (request_headers.query.togglesign == "true") no_signature = false;
@@ -71,7 +80,7 @@ Content-Type: audio/wav`;
var username = ssid_sessions[socket.ssid].getSessionData("subscriber_username");
var userdisplayname = wtvshared.htmlEntitize(ssid_sessions[socket.ssid].getSessionData("subscriber_name"));
var address = username + "@" + minisrv_config.config.service_name
var address = username + "@" + minisrv_config.config.domain_name
var notImplementedAlert = new clientShowAlert({
'image': minisrv_config.config.service_logo,
'message': "This feature is not available.",
@@ -102,19 +111,79 @@ Content-Type: audio/wav`;
attachments.push({ 'Content-Type': 'audio/wav', data: new message_voicemail_data });
}
}
if (newsgroup !== null) {
var request_is_async = true;
if (msg_body === null) {
doClientError("Please type a message to send to the group.");
sendToClient(socket, headers, '');
} else {
const Client = require('newsie').default
const client = new Client({
host: minisrv_config.services[request_headers.query['discuss-prefix'] || "wtv-news"].upstream_address,
port: minisrv_config.services[request_headers.query['discuss-prefix'] || "wtv-news"].upstream_port
})
var messagereturn = ssid_sessions[socket.ssid].mailstore.sendMessageToAddr(from_addr, to_addr, msg_body, msg_subject, userdisplayname, to_name, signature, attachments, msg_url, msg_url_title);
if (messagereturn !== true) {
var errpage = wtvshared.doErrorPage(400, messagereturn);
headers = errpage[0];
data = errpage[1];
client.connect()
.then(response => {
return client.post()
})
.then(response => {
if (response.code == 340) {
var articleData = {};
articleData.headers = {
'Relay-Version': "version zefie_wtvp_minisrv " + minisrv_config.version + "; site " + minisrv_config.config.domain_name,
'Posting-Version': "version zefie_wtvp_minisrv " + minisrv_config.version + "; site " + minisrv_config.config.domain_name,
'Path': "@" + minisrv_config.config.domain_name,
'From': from_addr,
'Newsgroups': newsgroup,
'Subject': msg_subject || "(No subject)",
'Message-ID': "<"+ssid_sessions[socket.ssid].generatePassword(16) + "@" + minisrv_config.config.domain_name+">",
'Date': strftime('%A, %d-%b-%y %k:%M:%S %z', new Date())
}
if (msg_body) {
articleData.body = msg_body.split("\n");
} else {
articleData.body = [];
}
return response.send(articleData);
} else {
clientErrorMsg("Could not send post. Server returned error " + response.code);
sendToClient(socket, headers, '');
return client.quit();
}
})
.then(response => {
if (response.code !== 240) {
clientErrorMsg("Could not send post. Server returned error " + response.code);
sendToClient(socket, headers, '');
} else {
headers = `300 OK
wtv-expire: wtv-news:/news?group=${newsgroup}
wtv-expire: wtv-mail:/sendmail
Location: wtv-news:/news?group=${newsgroup}`;
sendToClient(socket, headers, '');
return client.quit()
}
}).catch(e => {
console.log('usenet upstream uncaught error', e);
clientErrorMsg("Could not send post. Server returned unknown error");
sendToClient(socket, headers, '');
});
}
} else {
ssid_sessions[socket.ssid].deleteSessionData("mail_draft");
ssid_sessions[socket.ssid].deleteSessionData("mail_draft_attachments");
headers = `300 OK
var messagereturn = ssid_sessions[socket.ssid].mailstore.sendMessageToAddr(from_addr, to_addr, msg_body, msg_subject, userdisplayname, to_name, signature, attachments, msg_url, msg_url_title);
if (messagereturn !== true) {
var errpage = wtvshared.doErrorPage(400, messagereturn);
headers = errpage[0];
data = errpage[1];
} else {
ssid_sessions[socket.ssid].deleteSessionData("mail_draft");
ssid_sessions[socket.ssid].deleteSessionData("mail_draft_attachments");
headers = `300 OK
wtv-expire: wtv-mail:/listmail
wtv-expire: wtv-mail:/sendmail
Location: wtv-mail:/listmail`;
}
}
} else if (request_headers.query.saveoff) {
@@ -124,14 +193,15 @@ Location: wtv-mail:/listmail`;
msg_body: msg_body,
no_signature: no_signature,
msg_url: msg_url,
msg_url_title: msg_url_title
msg_url_title: msg_url_title,
newsgroup: newsgroup
}
ssid_sessions[socket.ssid].setSessionData("mail_draft", mail_draft_data);
headers = `200 OK
Content-type: text/html
wtv-expire: wtv-mail:/sendmail`;
}
} else {
} else {
headers = `200 OK
Content-type: text/html`;
@@ -195,7 +265,7 @@ location = "client:submitform?name=sendform&submitname=gabbing&submitvalue=true"
location.reload(); }
</script>
<title>
Write an e-mail message
${pageTitle}
</title>
</head>
<body bgcolor="#171726" text="${message_colors.text}" link="${message_colors.link}" vlink="${message_colors.vlink}" vspace=0 hspace=0>
@@ -203,6 +273,7 @@ Write an e-mail message
<input type=hidden name="wtv-saved-message-id" value="writemessage-outbox">
<input type=hidden name="message_reply_all_cc" value="">
<input type=hidden name="saveoff" value="true" autosubmit="onleave">
<input type=hidden name="discuss" value="${request_headers.query.discuss ? true : false}">
<sidebar width=109>
<table cellspacing=0 cellpadding=0>
<tr>
@@ -230,18 +301,22 @@ Write an e-mail message
<td height=1>
<tr>
<td><shadow><font sizerange=medium color=#E6CD4A>Mail list</font></shadow>
</table>
</table>`;
if (!newsgroup) {
data += `
<td width=5>
<tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
<tr>
<td width=10 height=26>
<td width=89 valgn=middle>
<td width=89 valgn=middle>;
<table cellspacing=0 cellpadding=0 href="client:openaddresspanel" id=addressbook>
<tr>
<td height=1>
<tr>
<td><shadow><font sizerange=medium color=#E6CD4A>Address</font></shadow>
</table>
<td><shadow><font sizerange=medium color=#E6CD4A>Address</font></shadow>;
</table>`;
}
data += `
<td width=5>
<tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
<tr>
@@ -288,7 +363,7 @@ Write an e-mail message
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td width=451 colspan=2 align=center bgcolor=#5B6C81>
<spacer type=vertical size=13>
<spacer type=vertical size=4>
<tr>
<td height=8 bgcolor=#171726 colspan=2>
<img src="wtv-mail:/content/images/CornerTop.gif" width=8 height=8>
@@ -314,7 +389,7 @@ Write an e-mail message
<spacer type=horizontal size=13>
<td width=370 maxlines=1>
<font sizerange=medium color=#D6D6D6><blackface>
Write an e-mail message
${pageTitle}
</blackface></font>
<!--
<td width=21>
@@ -358,8 +433,13 @@ ${address}
<td height=13 valign=middle colspan=2>
<img src="wtv-mail:/content/images/sendmail_panel_dots.gif" width=385 height=2>
<tr>
<td width=80 valign=top align=right>
<a href="client:openaddresspanel">To:</a>&nbsp;
<td width=80 valign=top align=right>`;
if (!request_headers.query.discuss) {
data += '<a href="client:openaddresspanel">To:</a>';
} else {
data += 'To:';
}
data += `&nbsp;
<td width=305 valign=top>
<textarea
bgcolor="${message_colors.bgcolor}"
@@ -377,7 +457,9 @@ growable
autoactivate
addresses
autoascii
nohighlight
nohighlight`;
if (newsgroup) { data += "\nreadonly" }
data += `
>${(to_addr) ? to_addr : ''}</textarea>
<tr>
<td height=13 valign=middle colspan=2>

View File

@@ -0,0 +1,157 @@
var minisrv_service_file = true;
headers = `200 OK
Connection: Keep-Alive
Content-Type: text/html`
data = `<HTML>
<HEAD>
<DISPLAY fontsize=medium>
<TITLE>Featured discussion groups</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="wtv-home:/ROMCache/WebTVLogoJewel.gif" 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-forum:/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>
Featured discussions
</table>
<td abswidth=20>
<tr>
<td>
<td WIDTH=198 HEIGHT=200 VALIGN=top ALIGN=left>
<a href="wtv-news:/news?group=webtv.users"><b>WebTV</b></a><br>
A moderated discussion with WebTV customers<br>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=18><BR>
<a href="wtv-news:/news?group=alt.discuss.webtv.hacking"><b>Hacking</b></a><br>
Not grandma friendly<br>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=18><BR>
<a href="wtv-news:/news?group=rec.autos.4x4"><b>4x4s</b></a><br>
The on and off-road four wheel drive vehicle<br>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=18><BR>
<td WIDTH=20>
<td WIDTH=198 HEIGHT=220 VALIGN=top ALIGN=left>
<a href="wtv-news:/news?group=webtv.plus"><b>WebTV Plus</b></a><br>
bf0 is for bitches and BPS is boring<br>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=18><BR>
<a href="wtv-news:/news?group=alt.discuss.midis"><b>MIDIs</b></a><br>
The best music format<br>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=18><BR>
<a href="wtv-news:/news?group=alt.discuss.html"><b>HTML</b></a><br>
Every timeline starts with HTML<br>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=18><BR>
</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>
Type a discussion topic<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>
&nbsp;
<font color=E7CE4A><shadow>
<input type=submit borderimage="file://ROM/Borders/ButtonBorder2.bif" value="Look for" usestyle>
</shadow></font>
</form>
</table>
</BODY>
</HTML>`;

View File

@@ -0,0 +1,625 @@
var minisrv_service_file = true;
async function clientConnect(client) {
response = await client.connect()
if (response.code == 200) {
return true;
}
return false;
}
async function listGroup(client, group) {
try {
return await client.listGroup(group)
} catch (e) {
console.log("WTVNews Error -", "Command: listGroup", e);
}
return null;
}
async function selectGroup(client, group) {
try {
response = await client.group(request_headers.query.group)
if (response.code == 211) {
return true;
}
return false;
} catch (e) {
console.log("WTVNews Error -", "Command: grop", e);
}
return false;
}
async function getArticle(client, articleID) {
try {
return await client.article(articleID)
} catch (e) {
console.log("WTVNews Error -", "Command: article", e);
}
return null;
}
async function getHeader(client, articleID) {
try {
return await client.head(articleID)
} catch (e) {
console.log("WTVNews Error -", "Command: head -", "Article ID: "+articleID, e);
}
return null;
}
async function quitUsenet(client) {
response = await client.quit()
if (response.code == 205) {
return true;
}
return false;
}
async function getHeaderObj(client, NGArticles) {
var messages = [];
for (var article in NGArticles) {
if (article == "getCaseInsensitiveKey") continue;
try {
var data = await getHeader(client, NGArticles[article]);
if (data.article) messages.push(data.article)
} catch (e) {
console.log(e, article);
}
}
return messages;
}
async function WebTVListGroup(client, group) {
var connected = await clientConnect(client)
if (connected) {
response = await selectGroup(client, group);
if (response) {
response = await listGroup(client, group);
if (response.code == 211) {
NGCount = response.group.number;
NGArticles = response.group.articleNumbers;
messages = await getHeaderObj(client, NGArticles);
quitUsenet(client);
headers = `200 OK
Connection: Keep-Alive
Content-Type: text/html
wtv-expire: wtv-news:/news?group=${request_headers.query.group}`
data = `<HTML>
<HEAD>
<script language=javascript>
if (top.frames.length > 1)
top.location="news:${request_headers.query.group}";
</script>
<TITLE>${request_headers.query.group}</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="wtv-home:/ROMCache/WebTVLogoJewel.gif" 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-mail:/sendmail?discuss=true&group=${request_headers.query.group}&discuss-prefix=wtv-news"
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">Post</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-forum:/images/BannerDiscuss.gif" width=50 height=165> <tr><td colspan=3 absheight=36>
</table>
</sidebar>
<body
bgcolor="191919" text="42BD52" link="1bb0f1"
vlink="826f7e"
hspace=0
vspace=0
logo="wtv-forum:/images/news_logo.gif">
<table cellspacing=0 cellpadding=0>
<tr>
<td rowspan=100 width=10 height=384 valign=top align=left>
<td height=16 width=416 valign=top align=left>
<td rowspan=100 width=20 height=384 valign=top align=left>
<tr>
<td height=31 valign=top>
<font size="+1" color="E7CE4A">
<blackface>
<shadow>
Group: ${request_headers.query.group}
</shadow>
</blackface>
</font>
</table>
<img src="wtv-home:/ROMCache/Spacer.gif" width=10 height=6>
<td width=180 valign=bottom align=right>
<table cellspacing=0 cellpadding=0>
<tr>
<td width=10 height=1 valign=top align=left>
<img src="wtv-home:/ROMCache/Spacer.gif" width=10 height=1>
<td height=33 width=256 valign=bottom>
<font size=4>
`
if (NGCount == 0) {
data += `This group has no postings`;
} else {
data += NGCount + " posting";
if (NGCount != 1)
data += "s"
}
data += `
</font>
<br>
<img src="wtv-home:/ROMCache/Spacer.gif" width=0 height=8>
<TABLE width=446 cellspacing=0 cellpadding=0>
<tr>
<td rowspan=4 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>
<tr>
<td height=6>
</TABLE>`
if (NGCount > 0) {
Object.keys(messages).forEach(function (k) {
var message = messages[k]
var message_date = message.headers.DATE;
data += `
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=10>
<td abswidth=426 height=42 valign=bottom>
<table cellspacing=0 cellpadding=0 href="wtv-news:/news?group=${request_headers.query.group}&article=${message.articleNumber}" id="${message.messageId}" nocolor selected>
<tr>
<td abswidth=426 maxlines=1>
<font color=1bb0f1>${(message.headers.SUBJECT) ? message.headers.SUBJECT : "(No Subject)"}
<tr>
<td maxlines=1>
<font size="-1" color=544f53><b>
${message.headers.FROM}, ${message.headers.DATE}
</b>
</table>
<td abswidth=10>
</table>`;
});
}
data += `
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=6><br>
<TABLE width=446 cellspacing=0 cellpadding=0>
<tr>
<td rowspan=4 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>
<tr>
<td height=6>
</TABLE>
<table cellspacing=0 cellpadding=0>
<tr>
<td width=10 height=1 valign=top align=left>
<img src="wtv-home:/ROMCache/Spacer.gif" width=10 height=1>
<td height=33 width=256 valign=bottom>
</BODY>
</HTML>`;
sendToClient(socket, headers, data);
} else {
var errpage = wtvshared.doErrorPage("400", "No such group.");
sendToClient(socket, errpage[0], errpage[1]);
}
}
}
}
async function WebTVShowMessage(client, group, article) {
var connected = await clientConnect(client)
if (connected) {
response = await selectGroup(client, group);
if (response) {
response = await getArticle(client, article);
console.log(response);
if (response.code == 220) {
headers = `200 OK
Content-type: text/html`;
var message_colors = ssid_sessions[socket.ssid].mailstore.defaultColors;
data = `<head>
<sendpanel
action="wtv-mail:/sendmail?message_forward_id=1&mailbox_name=inbox"
message="Forward this post to someone else."
label="Forward">
<title>
${(response.article.headers.SUBJECT) ? wtvshared.htmlEntitize(response.article.headers.SUBJECT) : '(No subject)'}
</title>
</head>
<print blackandwhite>
<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=${message_colors.bgcolor}>
<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 width=100%>
<tr>
<td abswidth=6>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1>
<td align=center>
<img src="wtv-mail:/ROMCache/WebTVLogoJewel.gif" width=87 height=67>
</table>
<td abswidth=5>
<tr>
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
<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 selected href="wtv-news:/news?group=${group}"
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">Group</font></shadow>
</table>
</table>
<td abswidth=5>
<tr>
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
<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 bgcolor=3d2f3a cellspacing=0 cellpadding=0>
<tr>
<td abswidth=5>
<td abswidth=88 valign=middle align=left >
<table cellspacing=0 cellpadding=0><tr><td><shadow><font color=5b4b58 sizerange=medium>Previous</font></shadow></table>
</table>
<td abswidth=5>
<tr>
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
<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 bgcolor=3d2f3a cellspacing=0 cellpadding=0>
<tr>
<td abswidth=5>
<td abswidth=88 valign=middle align=left >
<table cellspacing=0 cellpadding=0><tr><td><shadow><font color=5b4b58 sizerange=medium>Next</font></shadow></table>
</table>
<td abswidth=5>
<tr>
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
<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
xnocancel
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 color=5b4b58 sizerange=medium>Next New</font></shadow>
</table>
</table>
<td abswidth=5>
<tr>
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
<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
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="5b4b58">Mail to</font></shadow>
</table>
</table>
<td abswidth=5>
<tr>
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
<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&message_subject=${("Re: " + response.article.headers.SUBJECT)}&group=${response.article.headers.NEWSGROUPS}"
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">Respond</font></shadow>
</table>
</table>
<td abswidth=5>
<tr>
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
<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:/helpindex?title=Index_Mail&topic=2&subtopic=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">Help</font></shadow>
</table>
</table>
<td abswidth=5>
<tr>
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
<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=81 valign=bottom align=right>
<tr><td colspan=3 absheight=36>
</table>
</sidebar>
<body bgcolor=${message_colors.bgcolor}
text=${message_colors.text}
link=${message_colors.link}
vlink=${message_colors.vlink}
vspace=0
hspace=0>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=10 rowspan=99>
<td height=16>
<td rowspan=99>&nbsp;&nbsp;
<td>
<td abswidth=20 rowspan=99>
<tr>
<td colspan=3 height=39 valign=top>
<font color="E7CE4A" size=+1><blackface><shadow>
Post
<tr>
<td valign=top>
Group:
<td>
${wtvshared.htmlEntitize(response.article.headers.NEWSGROUPS)}
<tr>
<td valign=top>
Date: <td>
${console.log(Date.parse(response.article.headers.DATE))}
${strftime("%a, %b %e, %Y, %I:%M%P", new Date(Date.parse(response.article.headers.DATE) / 1000))}
<font size=-1> </font>
<tr>
<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)}`;
// }
data += `<tr>
<td nowrap valign=top>
<td>
</table>
<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 message_body = response.article.body.join("\n");
data += `
${wtvshared.htmlEntitize(message_body, true)}
<br>
<br>`;
data += `<p>
`;
/*
if (message.attachments) {
message.attachments.forEach((v, k) => {
if (v) {
console.log("*****************", v['Content-Type']);
switch (v['Content-Type']) {
case "image/jpeg":
data += `<img border=2 src="wtv-news:/get-attachment?message_id=${messageid}&attachment_id=${k}&group=${(message.to_group)}&wtv-title=Video%20Snapshot" width="380" height="290"><br><br>`;
break;
case "audio/wav":
data += `<table href="wtv-news:/get-attachment?message_id=${messageid}&attachment_id=${k}&group=${(message.to_group)}&wtv-title=Voice%20Mail" width=386 cellspacing=0 cellpadding=0>
<td align=left valign=middle><img src="wtv-mail:/ROMCache/FileSound.gif" align=absmiddle><font color="#189CD6">&nbsp;&nbsp;recording.wav (wav attachment)</font>
<td align=right valign=middle>
</table><br><br>
`;
break;
}
}
});
}
if (message.url) {
data += `Included Page: <a href="${(message.url)}">${wtvshared.htmlEntitize(message.url_title).replace(/&apos;/gi, "'")}`;
}
*/
data += `
</table>
</body>
</html>
`;
sendToClient(socket, headers, data);
} else {
var errpage = wtvshared.doErrorPage("400", "No such article in group <b>"+group+"</b>");
sendToClient(socket, errpage[0], errpage[1]);
}
} else {
var errpage = wtvshared.doErrorPage("400", "No such group: <b>"+group+"</b>");
sendToClient(socket, errpage[0], errpage[1]);
}
}
}
if (!minisrv_config.services[service_name].upstream_address || !minisrv_config.services[service_name].upstream_port) {
var errpage = doErrorPage("400");
headers = errpage[0];
data = errpage[1];
} else {
var request_is_async = true;
if (request_headers.query.group) {
const Client = require('newsie').default
const client = new Client({
host: minisrv_config.services[service_name].upstream_address,
port: minisrv_config.services[service_name].upstream_port
})
if (request_headers.query.article) {
WebTVShowMessage(client, request_headers.query.group, request_headers.query.article);
} else {
WebTVListGroup(client, request_headers.query.group);
}
}
}