more mail stuff
- todo: alot, but mainly track new/read and get local working
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
headers = `200 OK
|
||||
Content-type: text/html`;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ 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.mailstoreExists() ? '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 (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"
|
||||
|
||||
@@ -54,8 +54,7 @@ Welcome to Mail
|
||||
<td>
|
||||
<td valign=top>
|
||||
In Mail, you can exchange typed messages—called
|
||||
<i>e-mail</i>—with anyone in the world who has an e-mail
|
||||
address. This is your e-mail address:
|
||||
<i>m-mail</i>—with anyone who is on ${minisrv_config.config.service_name}, as well as anyone using other compatible MiniSrvs around the world. This is your m-mail address:
|
||||
<blockquote>
|
||||
<b>${ssid_sessions[socket.ssid].getSessionData("subscriber_username")}@${minisrv_config.config.service_name}</b>
|
||||
</blockquote>
|
||||
@@ -79,10 +78,10 @@ choose this link:
|
||||
</table>
|
||||
<tr>
|
||||
<td valign=top height=55 align=right>
|
||||
<form>
|
||||
<form method="POST" action="wtv-mail:/listmail">
|
||||
<input type="hidden" name="intro_seen" value="true">
|
||||
<font color=ffcf69><shadow>
|
||||
<input type=button usestyle borderimage="file://ROM/Borders/ButtonBorder2.bif"
|
||||
action="wtv-mail:/listmail"
|
||||
<input type=submit usestyle borderimage="file://ROM/Borders/ButtonBorder2.bif"
|
||||
value="Begin"
|
||||
width='110'
|
||||
selected>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 98 B |
@@ -8,57 +8,66 @@ function mail_end_error(msg) {
|
||||
data = errpage[1];
|
||||
}
|
||||
|
||||
// check if mailstore exists (returns null if guest)
|
||||
mailstore_exists = ssid_sessions[socket.ssid].mailstore.mailstoreExists();
|
||||
var intro_seen = ssid_sessions[socket.ssid].mailstore.checkMailIntroSeen();
|
||||
if (!intro_seen && !request_headers.query.intro_seen) {
|
||||
// user is trying to bypass the intro screen
|
||||
headers = "300 OK\nLocation: wtv-mail:/DiplomaMail";
|
||||
} else {
|
||||
if (!intro_seen && request_headers.query.intro_seen) {
|
||||
// User has come from intro
|
||||
ssid_sessions[socket.ssid].mailstore.setMailIntroSeen(true);
|
||||
}
|
||||
// check if mailstore exists (returns null if guest)
|
||||
mailstore_exists = ssid_sessions[socket.ssid].mailstore.mailstoreExists();
|
||||
|
||||
// create mailstore if it doesnt exist (also returns null if guest)
|
||||
if (!mailstore_exists) mailstore_exists = ssid_sessions[socket.ssid].mailstore.createMailstore();
|
||||
// create mailstore if it doesnt exist (also returns null if guest)
|
||||
if (!mailstore_exists) mailstore_exists = ssid_sessions[socket.ssid].mailstore.createMailstore();
|
||||
|
||||
if (mailstore_exists) {
|
||||
// mailstore exists and user is not guest
|
||||
if (mailstore_exists) {
|
||||
// mailstore exists and user is not guest
|
||||
|
||||
var default_limit = (minisrv_config.services[service_name].messages_per_page) ? minisrv_config.services[service_name].messages_per_page : 25; // user config or 25
|
||||
var mailbox = (request_headers.query.mailbox) ? parseInt(request_headers.query.mailbox) : 0;
|
||||
var limit = (request_headers.query.limit) ? parseInt(request_headers.query.limit) : default_limit;
|
||||
var reverse_sort = (request_headers.query.reverse_sort) ? true : false;
|
||||
var page = (request_headers.query.page) ? parseInt(request_headers.query.page) : 0;
|
||||
var default_limit = (minisrv_config.services[service_name].messages_per_page) ? minisrv_config.services[service_name].messages_per_page : 25; // user config or 25
|
||||
var mailbox = (request_headers.query.mailbox) ? parseInt(request_headers.query.mailbox) : 0;
|
||||
var limit = (request_headers.query.limit) ? parseInt(request_headers.query.limit) : default_limit;
|
||||
var reverse_sort = (request_headers.query.reverse_sort) ? true : false;
|
||||
var page = (request_headers.query.page) ? parseInt(request_headers.query.page) : 0;
|
||||
|
||||
// get mailbox name
|
||||
var mailbox_name = ssid_sessions[socket.ssid].mailstore.getMailboxById(parseInt(mailbox));
|
||||
// get mailbox name
|
||||
var mailbox_name = ssid_sessions[socket.ssid].mailstore.getMailboxById(parseInt(mailbox));
|
||||
|
||||
// if false or null, then mailbox is invalid
|
||||
if (!mailbox_name) {
|
||||
mail_end_error("Invalid Mailbox ID");
|
||||
} else {
|
||||
// mailboxid is ok
|
||||
if (!ssid_sessions[socket.ssid].mailstore.mailboxExists(mailbox)) {
|
||||
// mailbox does not yet exist, create it
|
||||
var mailbox_exists = ssid_sessions[socket.ssid].mailstore.createMailbox(mailbox);
|
||||
if (!mailbox_exists) {
|
||||
// failed to create mailbox for some reason
|
||||
mail_end_error();
|
||||
} else {
|
||||
if (mailbox === 0) {
|
||||
// Just created Inbox for the first time, so create the welcome message
|
||||
ssid_sessions[socket.ssid].mailstore.createWelcomeMessage();
|
||||
// if false or null, then mailbox is invalid
|
||||
if (!mailbox_name) {
|
||||
mail_end_error("Invalid Mailbox ID");
|
||||
} else {
|
||||
// mailboxid is ok
|
||||
if (!ssid_sessions[socket.ssid].mailstore.mailboxExists(mailbox)) {
|
||||
// mailbox does not yet exist, create it
|
||||
var mailbox_exists = ssid_sessions[socket.ssid].mailstore.createMailbox(mailbox);
|
||||
if (!mailbox_exists) {
|
||||
// failed to create mailbox for some reason
|
||||
mail_end_error();
|
||||
} else {
|
||||
if (mailbox === 0) {
|
||||
// Just created Inbox for the first time, so create the welcome message
|
||||
ssid_sessions[socket.ssid].mailstore.createWelcomeMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var message_list = ssid_sessions[socket.ssid].mailstore.listMessages(mailbox, limit, reverse_sort, (page * limit))
|
||||
var total_message_count = ssid_sessions[socket.ssid].mailstore.countMessages(mailbox);
|
||||
var username = ssid_sessions[socket.ssid].getSessionData("subscriber_username");
|
||||
var notImplementedAlert = new clientShowAlert({
|
||||
'image': minisrv_config.config.service_logo,
|
||||
'message': "This feature is not available.",
|
||||
'buttonlabel1': "Okay",
|
||||
'buttonaction1': "client:donothing",
|
||||
'noback': true,
|
||||
}).getURL();
|
||||
var message_list = ssid_sessions[socket.ssid].mailstore.listMessages(mailbox, limit, reverse_sort, (page * limit))
|
||||
var total_message_count = ssid_sessions[socket.ssid].mailstore.countMessages(mailbox);
|
||||
var username = ssid_sessions[socket.ssid].getSessionData("subscriber_username");
|
||||
var notImplementedAlert = new clientShowAlert({
|
||||
'image': minisrv_config.config.service_logo,
|
||||
'message': "This feature is not available.",
|
||||
'buttonlabel1': "Okay",
|
||||
'buttonaction1': "client:donothing",
|
||||
'noback': true,
|
||||
}).getURL();
|
||||
|
||||
headers = `200 OK
|
||||
headers = `200 OK
|
||||
Content-type: text/html`;
|
||||
|
||||
data = `<sendpanel action="wtv-mail:/sendmail"
|
||||
data = `<sendpanel action="wtv-mail:/sendmail"
|
||||
message="Write a new e-mail message"
|
||||
label="Write">
|
||||
<savepanel
|
||||
@@ -94,7 +103,7 @@ label="View saved e-mail messages">
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valign=middle>
|
||||
<table cellspacing=0 cellpadding=0 href="${notImplementedAlert}"
|
||||
<table cellspacing=0 cellpadding=0 href="wtv-mail:/sendmail"
|
||||
>
|
||||
<tr>
|
||||
<td height=1>
|
||||
@@ -107,7 +116,7 @@ label="View saved e-mail messages">
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valign=middle>
|
||||
<table cellspacing=0 cellpadding=0 href="wtv-mail:/folders"
|
||||
<table cellspacing=0 cellpadding=0 href="${notImplementedAlert}"
|
||||
>
|
||||
<tr>
|
||||
<td height=1>
|
||||
@@ -178,33 +187,23 @@ label="View saved e-mail messages">
|
||||
<td height=80>
|
||||
<img src="wtv-mail:/content/images/Mail.gif" width=87 height=45>
|
||||
`;
|
||||
var icon_image = null;
|
||||
switch (mailbox_name) {
|
||||
case "Inbox":
|
||||
switch (total_message_count) {
|
||||
case 0:
|
||||
icon_image = "OpenMailbox0.gif";
|
||||
break;
|
||||
case 1:
|
||||
icon_image = "OpenMailbox1.gif";
|
||||
break;
|
||||
default:
|
||||
icon_image = "OpenMailbox2.gif";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "Sent":
|
||||
icon_image = "MailboxSent.gif";
|
||||
break;
|
||||
case "Trash":
|
||||
icon_image = "MailboxDiscard.gif";
|
||||
break;
|
||||
default:
|
||||
icon_image = "MailboxStorage.gif";
|
||||
break;
|
||||
}
|
||||
var icon_image = null;
|
||||
switch (mailbox_name) {
|
||||
case "Inbox":
|
||||
icon_image = ssid_sessions[socket.ssid].mailstore.getMailboxIcon();
|
||||
break;
|
||||
case "Sent":
|
||||
icon_image = "MailboxSent.gif";
|
||||
break;
|
||||
case "Trash":
|
||||
icon_image = "MailboxDiscard.gif";
|
||||
break;
|
||||
default:
|
||||
icon_image = "MailboxStorage.gif";
|
||||
break;
|
||||
}
|
||||
|
||||
data += `
|
||||
data += `
|
||||
<img src="wtv-mail:/content/images/${icon_image}" width=74 height=45 >
|
||||
<td width=250 align=left><font sizerange=small>
|
||||
</table>
|
||||
@@ -243,9 +242,9 @@ label="View saved e-mail messages">
|
||||
<spacer type=horizontal size=13>
|
||||
<td bgcolor=#171726 width="438" valign="top">
|
||||
<spacer type=vertical size=13><br>`;
|
||||
if (message_list) {
|
||||
if (message_list) {
|
||||
|
||||
data += `
|
||||
data += `
|
||||
<font sizerange=medium> ${total_message_count} e-mail message${(total_message_count != 1) ? 's' : ''} for
|
||||
<table cellspacing=0 cellpadding=0 border=0>
|
||||
<TR><TD maxlines="1">
|
||||
@@ -266,10 +265,10 @@ ${username}@${minisrv_config.config.service_name}
|
||||
<spacer type=vertical size=1>
|
||||
<hr width=422 align=left>
|
||||
`;
|
||||
Object.keys(message_list).forEach(function (k) {
|
||||
var message = message_list[k];
|
||||
console.log(message);
|
||||
data += `<spacer type=vertical size=5>
|
||||
Object.keys(message_list).forEach(function (k) {
|
||||
var message = message_list[k];
|
||||
console.log(message);
|
||||
data += `<spacer type=vertical size=5>
|
||||
<table cellspacing=0 cellpadding=0 border=0>
|
||||
<tr>
|
||||
<td href="readmail?message_id=${message.id}#next" id="id${message.id}" selected>
|
||||
@@ -289,25 +288,25 @@ ${(message.subject) ? message.subject : "(No Subject)"}
|
||||
<td abswidth=47 maxlines=1>
|
||||
<font color=#7A9FCC>
|
||||
`;
|
||||
var message_date = new Date(message.date * 1000);
|
||||
data += (message_date.getMonth() + 1) + "/" + message_date.getDate() + "\n";
|
||||
data += `
|
||||
var message_date = new Date(message.date * 1000);
|
||||
data += (message_date.getMonth() + 1) + "/" + message_date.getDate() + "\n";
|
||||
data += `
|
||||
</font>
|
||||
</table>
|
||||
<tr>
|
||||
<td height=5>`;
|
||||
});
|
||||
} else {
|
||||
data += `
|
||||
});
|
||||
} else {
|
||||
data += `
|
||||
<font sizerange=medium> No ${(mailbox_name == "Inbox") ? `new e-mail messages for<table cellspacing=0 cellpadding=0 border=0>
|
||||
<TR><TD maxlines="1">
|
||||
${username}@${minisrv_config.config.service_name}
|
||||
</TD></TR>
|
||||
</TABLE>` : 'e-mail messages in mailbox '+mailbox_name}
|
||||
</TABLE>` : 'e-mail messages in mailbox ' + mailbox_name}
|
||||
</font><br>
|
||||
`;
|
||||
}
|
||||
data += `
|
||||
}
|
||||
data += `
|
||||
<spacer type=vertical size=6>
|
||||
</table>
|
||||
</body>
|
||||
@@ -315,7 +314,8 @@ data += `
|
||||
`;
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
mail_end_error("Access Denied");
|
||||
}
|
||||
} else {
|
||||
mail_end_error("Access Denied");
|
||||
}
|
||||
273
zefie_wtvp_minisrv/ServiceVault/wtv-mail/readmail.js
Normal file
273
zefie_wtvp_minisrv/ServiceVault/wtv-mail/readmail.js
Normal file
@@ -0,0 +1,273 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var mailstore_exists = false;
|
||||
|
||||
function mail_end_error(msg) {
|
||||
var errpage = doErrorPage("400", msg);
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
}
|
||||
|
||||
var intro_seen = ssid_sessions[socket.ssid].mailstore.checkMailIntroSeen();
|
||||
if (!intro_seen && !request_headers.query.intro_seen) {
|
||||
// user is trying to bypass the intro screen
|
||||
headers = "300 OK\nLocation: wtv-mail:/DiplomaMail";
|
||||
} else {
|
||||
if (!request_headers.query.message_id) {
|
||||
mail_end_error("Message ID Required");
|
||||
} else {
|
||||
var messageid = request_headers.query.message_id;
|
||||
var message = ssid_sessions[socket.ssid].mailstore.getMessageByID(messageid);
|
||||
if (!message) {
|
||||
mail_end_error("Invalid Message ID");
|
||||
} else {
|
||||
var notImplementedAlert = new clientShowAlert({
|
||||
'image': minisrv_config.config.service_logo,
|
||||
'message': "This feature is not available.",
|
||||
'buttonlabel1': "Okay",
|
||||
'buttonaction1': "client:donothing",
|
||||
'noback': true,
|
||||
}).getURL();
|
||||
|
||||
headers = `200 OK
|
||||
Content-type: text/html`;
|
||||
|
||||
data = `<wtvnoscript>
|
||||
<sendpanel
|
||||
action = "wtv-mail:/sendmail?message_forward_id=14&mailbox_name=inbox"
|
||||
message = "Forward this message to someone else."
|
||||
label = "Forward">
|
||||
<savepanel
|
||||
action = "client:showsplash?image=wtv-mail:/ROMCache/OpenMailbox3.gif&message=Saving%20to%20storage&showpage=true&action=wtv-mail:/readmail%3Fmailbox_name%3Dinbox%26message_move%3Dmbox%26message_id%3D14%26selected%3Dsave"
|
||||
message = "Save this message with your stored mail."
|
||||
label = "Save"
|
||||
xnocancel>
|
||||
<HTML>
|
||||
<head>
|
||||
<title>
|
||||
${message.subject}
|
||||
</title>
|
||||
</head>
|
||||
<body
|
||||
bgcolor="#171726"
|
||||
text="#82A9D9"
|
||||
link="#BDA73A" vlink="#62B362" vspace=0 hspace=0>
|
||||
<sidebar width=109>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td width=104 height=420 bgcolor=#262E3D valign=top>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td height=7 colspan=3>
|
||||
<spacer type=vertical size=7>
|
||||
<tr>
|
||||
<td width=7>
|
||||
<spacer type=horizontal size=7>
|
||||
<td width=87 href="wtv-home:/home">
|
||||
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
|
||||
<td width=10>
|
||||
<spacer type=horizontal size=10>
|
||||
</table>
|
||||
<spacer type=vertical size=6>
|
||||
<table cellspacing=0 cellpadding=0 border=0>
|
||||
<tr>
|
||||
<td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valign=middle>
|
||||
<table cellspacing=0 cellpadding=0 href="wtv-mail:/listmail?mailbox=0#id${messageid}"
|
||||
>
|
||||
<tr>
|
||||
<td height=1>
|
||||
<tr>
|
||||
<td><shadow><font sizerange=medium color=#E6CD4A>Mail list</font></shadow>
|
||||
</table>
|
||||
<td width=5>
|
||||
<tr>
|
||||
<td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valign=middle>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td height=1>
|
||||
<tr>
|
||||
<td><shadow><font sizerange=medium color=#596C75 href="${notImplementedAlert}">Previous</font></shadow>
|
||||
</table>
|
||||
<td width=5>
|
||||
<tr>
|
||||
<td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valign=middle>
|
||||
<table cellspacing=0 cellpadding=0 id=next href="${notImplementedAlert}" >
|
||||
<tr>
|
||||
<td height=1>
|
||||
<tr>
|
||||
<td><shadow><font sizerange=medium color=#E6CD4A>Next</font></shadow>
|
||||
</table>
|
||||
<td width=5>
|
||||
<tr>
|
||||
<td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valign=middle>
|
||||
<table cellspacing=0 cellpadding=0 href="client:showsplash?image=wtv-mail:/content/images/OpenMailbox3.gif&message=Discarding%20Message&showpage=true&action=wtv-mail%3A%2Freadmail%3Fmessage_delete%3Dtrue%26message_id%3D${messageid}%26mailbox_name%3DInbox%26selected%3Ddelete"
|
||||
xnocancel
|
||||
id=delete
|
||||
>
|
||||
<tr>
|
||||
<td height=1>
|
||||
<tr>
|
||||
<td><shadow><font sizerange=medium color=#E6CD4A>Discard</font></shadow>
|
||||
</table>
|
||||
<td width=5>
|
||||
<tr>
|
||||
<td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valign=middle>
|
||||
<table cellspacing=0 cellpadding=0 href="client:showsplash?image=wtv-mail:/content/images/OpenMailbox3.gif&message=Saving%20Message&showpage=true&action=wtv-mail:/readmail%3Fmessage_move%3DSaved%26mailbox_name%3DInbox%26message_id%3D${messageid}%26selected%3Dsave"
|
||||
xnocancel
|
||||
id=save
|
||||
>
|
||||
<tr>
|
||||
<td height=1>
|
||||
<tr>
|
||||
<td><shadow><font sizerange=medium color=#E6CD4A>Save</font></shadow>
|
||||
</table>
|
||||
<td width=5>
|
||||
<tr>
|
||||
<td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valign=middle>
|
||||
<table cellspacing=0 cellpadding=0 href="wtv-mail:/sendmail?message_reply_id=${messageid}&mailbox_name=Inbox&selected=body&reply_all=false"
|
||||
xnocancel
|
||||
id=save
|
||||
>
|
||||
<tr>
|
||||
<td height=1>
|
||||
<tr>
|
||||
<td><shadow><font sizerange=medium color=#E6CD4A>Reply</font></shadow>
|
||||
</table>
|
||||
<td width=5>
|
||||
<tr>
|
||||
<td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valign=middle>
|
||||
<table cellspacing=0 cellpadding=0 href="wtv-mail:/sendmail?message_forward_id=${messageid}&mailbox_name=Inbox"
|
||||
xnocancel
|
||||
id=save
|
||||
>
|
||||
<tr>
|
||||
<td height=1>
|
||||
<tr>
|
||||
<td><shadow><font sizerange=medium color=#E6CD4A>Forward</font></shadow>
|
||||
</table>
|
||||
<td width=5>
|
||||
<tr>
|
||||
<td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
</table>
|
||||
<td width=5 bgcolor=#5B6C81>
|
||||
</table>
|
||||
</sidebar>
|
||||
<table cellspacing=0 cellpadding=0 border=0>
|
||||
<tr>
|
||||
<td width=451 colspan=2 align=center bgcolor=#5B6C81>
|
||||
<spacer type=vertical size=13>
|
||||
<tr>
|
||||
<td height=8 bgcolor=#171726 colspan=2>
|
||||
<img src="wtv-mail:/content/images/CornerTop.gif" width=8 height=8>
|
||||
<tr>
|
||||
<td bgcolor=#171726 width=451 valign=top>
|
||||
<table cellspacing=0 cellpadding=0 width=451>
|
||||
<tr>
|
||||
<td bgcolor=#171726 width=13>
|
||||
<spacer type=horizontal size=13>
|
||||
<td height=9>
|
||||
</table>
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<table cellspacing=0 cellpadding=0 bgcolor=#2C323D>
|
||||
<tr>
|
||||
<td width=451 absheight=25>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td width=13 absheight=25>
|
||||
<spacer type=horizontal size=13>
|
||||
<td width=370 maxlines=1>
|
||||
<font sizerange=medium color=#D6D6D6><blackface>
|
||||
E-mail message
|
||||
</blackface></font>
|
||||
<td width=21>
|
||||
<!--
|
||||
<img src="wtv-mail:/content/images/widget.gif" width=16 height=16 noprint>
|
||||
<td width=36>
|
||||
<spacer type=vertical size=1><br>
|
||||
<a href="wtv-guide:/help?topic=Mail&subtopic=Index&appName=Mail" ><img src="wtv-mail:/content/images/mail_help_image.gif" width=35 height=17 noprint></a>
|
||||
-->
|
||||
<td width=13>
|
||||
<spacer type=horizontal size=13>
|
||||
</table>
|
||||
</table>
|
||||
</table>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td width=13 rowspan=2>
|
||||
<td height=15>
|
||||
<spacer type=vertical size=15>
|
||||
<td width=13 rowspan=2>
|
||||
<tr>
|
||||
<td abswidth=425>
|
||||
<table cellspacing=0 cellpadding=0 border=0>
|
||||
<tr>
|
||||
<td valign=top>
|
||||
From:
|
||||
<td width=10>
|
||||
<td>`;
|
||||
if (message.from_name != message.from_addr) {
|
||||
data += `${html_entities.encode(message.from_addr)}<a href="client:showalert?sound=none&message=To%20add%20%3Cblackface%3E${escape(escape(message.from_name))}%3C%2Fblackface%3E%20to%20your%20Address%20book,%20choose%20%3Cb%3EAdd%3C%2Fb%3E.&buttonlabel2=Cancel&buttonaction2=client:donothing&buttonlabel1=Add&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">(${html_entities.encode(message.from_name)})</a>`;
|
||||
} else {
|
||||
data += `${html_entities.encode(message.from_addr)}`;
|
||||
}
|
||||
|
||||
data += `<tr>
|
||||
<td valign=top>
|
||||
Date:
|
||||
<td>
|
||||
<td>
|
||||
${strftime("%a, %b %e, %Y, %I:%M %P",new Date(message.date * 1000))} (UTC)
|
||||
<tr>
|
||||
<td valign=top>
|
||||
To:
|
||||
<td>
|
||||
<td>
|
||||
${html_entities.encode(message.to_addr)} ${(html_entities.encode(message.to_name)) ? '(' + html_entities.encode(message.to_name) + ')' : ''}
|
||||
<tr>
|
||||
<td nowrap valign=top>
|
||||
Subject: <td>
|
||||
<td>
|
||||
${html_entities.encode(message.subject)}
|
||||
<tr>
|
||||
<td height=10>
|
||||
<spacer type=vertical size=10>
|
||||
</table>
|
||||
<input type=hidden name=message_safe value=true>
|
||||
<table cellspacing=0 cellpadding=0 border=0>
|
||||
<tr>
|
||||
<td width=425>
|
||||
<p>
|
||||
${html_entities.encode(message.body).replace("\n", "<br>")}
|
||||
${(message.signature) ? '<embed src="wtv-mail:/get-signature?message_id=${messageid}>' : ''}
|
||||
<p>
|
||||
<p>
|
||||
</table>
|
||||
</table>
|
||||
</body>
|
||||
</HTML>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
338
zefie_wtvp_minisrv/ServiceVault/wtv-mail/sendmail.js
Normal file
338
zefie_wtvp_minisrv/ServiceVault/wtv-mail/sendmail.js
Normal file
@@ -0,0 +1,338 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var intro_seen = ssid_sessions[socket.ssid].mailstore.checkMailIntroSeen();
|
||||
if (!intro_seen && !request_headers.query.intro_seen) {
|
||||
// user is trying to bypass the intro screen
|
||||
headers = "300 OK\nLocation: wtv-mail:/DiplomaMail";
|
||||
} else {
|
||||
|
||||
var doClientError = function (msg) {
|
||||
var clientErrorMsg = new clientShowAlert({
|
||||
'image': minisrv_config.config.service_logo,
|
||||
'message': msg,
|
||||
'buttonlabel1': "Okay",
|
||||
'buttonaction1': "client:donothing",
|
||||
'noback': true,
|
||||
}).getURL();
|
||||
|
||||
headers = "300 OK\nwtv-visit: " + clientErrorMsg;
|
||||
}
|
||||
|
||||
var username = ssid_sessions[socket.ssid].getSessionData("subscriber_username");
|
||||
var userdisplayname = html_entities.encode(ssid_sessions[socket.ssid].getSessionData("subscriber_name"));
|
||||
var address = username + "@" + minisrv_config.config.service_name
|
||||
var notImplementedAlert = new clientShowAlert({
|
||||
'image': minisrv_config.config.service_logo,
|
||||
'message': "This feature is not available.",
|
||||
'buttonlabel1': "Okay",
|
||||
'buttonaction1': "client:donothing",
|
||||
'noback': true,
|
||||
}).getURL();
|
||||
|
||||
|
||||
headers = `200 OK
|
||||
Content-type text/html`;
|
||||
|
||||
data = `<display poweroffalert >
|
||||
<sendpanel
|
||||
action="javascript:Submit()"
|
||||
message="Send this message now"
|
||||
label="Send message">
|
||||
<savepanel message="Messages that you are writing cannot be saved. Send it to yourself if you would like a copy.">
|
||||
<HTML>
|
||||
<head>
|
||||
<script language=javascript>
|
||||
function Submit() { if (document.sendform.message_to.value == "") { location = "client:showalert?message=Your%20message%20could%20not%20be%20sent.%3Cp%3E%0AYou%20must%20specify%20an%20addressee%20in%20the%20%3Cblackface%3ETo%3A%3C%2Fblackface%3E%20area.%0A&buttonLabel1=Continue%0A&buttonAction1=client%3Adonothing&buttonLabel2=";
|
||||
} else { location = "client:showsplash?message=Sending%20Message&animation=file://ROM/Animations/mail.ani&action=client:submitform%3Fname%3Dsendform%26submitname%3Dsendoff%26submitvalue%3DSend";
|
||||
}
|
||||
}
|
||||
function ErasingMedia(victim) { var myURL;
|
||||
myURL = "client:submitform?name=sendform&submitvalue=false" + "&submitname=" + victim;
|
||||
if (victim == "gabbing") { document.forms.sendform.elements.message_voicemail_data.disabled = true;
|
||||
}
|
||||
if (victim == "snapping") { document.forms.sendform.elements.message_snapshot_data.disabled = true;
|
||||
}
|
||||
location = myURL;
|
||||
location.reload(); }
|
||||
function Signing(desiredState) { var myURL;
|
||||
myURL="client:submitform?name=sendform&submitvalue=false"+"&submitname=togglesign";
|
||||
location = myURL;
|
||||
location.reload();
|
||||
}
|
||||
function DoneSnapping() { location = "client:submitform?name=sendform&submitname=snapping&submitvalue=true";
|
||||
location.reload(); }
|
||||
function DoneGabbing() { var myURL;
|
||||
myURL = "client:submitform?name=sendform&submitname=gabbing&submitvalue=cache%3Avoicemail.wav";
|
||||
location = "client:submitform?name=sendform&submitname=gabbing&submitvalue=true";
|
||||
location.reload(); }
|
||||
</script>
|
||||
<title>
|
||||
Write an e-mail message
|
||||
</title>
|
||||
</head>
|
||||
<body bgcolor="#171726" text="#82A9D9" link="#BDA73A" vlink="#62B362" vspace=0 hspace=0>
|
||||
<form action="wtv-mail:/sendmail#focus" method="post" name=sendform >
|
||||
<input type=hidden name=skey value="Kx0uv4a00C4">
|
||||
<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">
|
||||
<sidebar width=109>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td width=104 height=420 bgcolor=#262E3D valign=top>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td height=7 colspan=3>
|
||||
<spacer type=vertical size=7>
|
||||
<tr>
|
||||
<td width=7>
|
||||
<spacer type=horizontal size=7>
|
||||
<td width=87 href="wtv-home:/home">
|
||||
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
|
||||
<td width=10>
|
||||
<spacer type=horizontal size=10>
|
||||
</table>
|
||||
<spacer type=vertical size=6>
|
||||
<table cellspacing=0 cellpadding=0 border=0>
|
||||
<tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valgn=middle>
|
||||
<table cellspacing=0 cellpadding=0 href="wtv-mail:/listmail" >
|
||||
<tr>
|
||||
<td height=1>
|
||||
<tr>
|
||||
<td><shadow><font sizerange=medium color=#E6CD4A>Mail list</font></shadow>
|
||||
</table>
|
||||
<td width=5>
|
||||
<tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<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 width=5>
|
||||
<tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valgn=middle>
|
||||
<table cellspacing=0 cellpadding=0 href="client:videocapture?notify=javascript%3ADoneSnapping()&device=video&width=100%25&height=100%25&name=cache%3Asnapshot.jpg&donebuttonlabel=Add%20to%20Message&open" id=addressbook>
|
||||
<tr>
|
||||
<td height=1>
|
||||
<tr>
|
||||
<td><shadow><font sizerange=medium color=#E6CD4A>Photo</font></shadow>
|
||||
</table>
|
||||
<td width=5>
|
||||
<tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valgn=middle>
|
||||
<table cellspacing=0 cellpadding=0 href="client:soundcapture?notify=javascript%3ADoneGabbing()&device=audio&rate=8000&name=cache%3Avoicemail.wav&donebuttonlabel=Add%20to%20Message&open" id=addressbook>
|
||||
|
||||
<tr>
|
||||
<td height=1>
|
||||
<tr>
|
||||
<td><shadow><font sizerange=medium color=#E6CD4A>Recording</font></shadow>
|
||||
</table>
|
||||
<td width=5>
|
||||
<tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valgn=middle>
|
||||
<table cellspacing=0 cellpadding=0 href="client:showalert?sound=none&message=Are%20you%20sure%20you%20want%20to%20erase%20this%20entire%20message%3F&buttonlabel2=Don't%20Erase&buttonaction2=client:donothing&buttonlabel1=Erase&buttonaction1=wtv-mail:/sendmail%3Fclear%3Dtrue%26wtv-saved-message-id%3Dwritemessage-outbox" id=addressbook>
|
||||
<tr>
|
||||
<td height=1>
|
||||
<tr>
|
||||
<td><shadow><font sizerange=medium color=#E6CD4A>Erase</font></shadow>
|
||||
</table>
|
||||
<td width=5>
|
||||
<tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valgn=middle>
|
||||
</table>
|
||||
</sidebar>
|
||||
<table cellspacing=0 cellpadding=0 border=0>
|
||||
<tr>
|
||||
<td width=451 colspan=2 align=center bgcolor=#5B6C81>
|
||||
<spacer type=vertical size=13>
|
||||
<tr>
|
||||
<td height=8 bgcolor=#171726 colspan=2>
|
||||
<img src="wtv-mail:/content/images/CornerTop.gif" width=8 height=8>
|
||||
<tr>
|
||||
<td bgcolor=#171726 width=451 valign=top>
|
||||
<table cellspacing=0 cellpadding=0 width=451>
|
||||
<tr>
|
||||
<td bgcolor=#171726 width=13>
|
||||
<spacer type=horizontal size=13>
|
||||
<td height=80>
|
||||
<img src="wtv-mail:/content/images/Mail.gif" width=87 height=45>
|
||||
<img src="wtv-mail:/content/images/${ssid_sessions[socket.ssid].mailstore.getMailboxIcon()}" width=74 height=45 transparency=60>
|
||||
<td width=250 align=left><font sizerange=small>
|
||||
</table>
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<table cellspacing=0 cellpadding=0 bgcolor=#2C323D>
|
||||
<tr>
|
||||
<td width=451 absheight=25>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td width=13 absheight=25>
|
||||
<spacer type=horizontal size=13>
|
||||
<td width=370 maxlines=1>
|
||||
<font sizerange=medium color=#D6D6D6><blackface>
|
||||
Write an e-mail message
|
||||
</blackface></font>
|
||||
<!--
|
||||
<td width=21>
|
||||
<img src="wtv-mail:/content/images/widget.gif" width=16 height=16 noprint>
|
||||
<td width=36>
|
||||
<spacer type=vertical size=1><br>
|
||||
<a href="wtv-guide:/help?topic=Mail&subtopic=Index&appName=Mail" ><img src="wtv-mail:/content/images/mail_help_image.gif" width=35 height=17 noprint></a> -->
|
||||
<td width=13>
|
||||
<spacer type=horizontal size=13>
|
||||
</table>
|
||||
</table>
|
||||
</table>
|
||||
<table cellspacing=0 cellpadding=0 border=0>
|
||||
<tr>
|
||||
<td bgcolor=#171726 width=13>
|
||||
<spacer type=horizontal size=13>
|
||||
<td bgcolor=#171726 width=438 valign=top>
|
||||
<spacer type=vertical size=5><br>
|
||||
<table cellspacing=0 cellpadding=0 bgcolor="#1F2033">
|
||||
<tr>
|
||||
<td absheight=2 colspan=5 bgcolor=#495360>
|
||||
<tr>
|
||||
<td abswidth=2 bgcolor=#495360>
|
||||
<td absheight=13 colspan=3>
|
||||
<td abswidth=2 bgcolor=#000000>
|
||||
<tr>
|
||||
<td abswidth=2 bgcolor=#495360>
|
||||
<td abswidth=13>
|
||||
<td abswidth=385>
|
||||
<table cellspacing=0 cellpadding=0> <tr>
|
||||
<td width=80 valign=top align=right>
|
||||
<font color=#82A9D9>From: </font>
|
||||
<td width=305 valign=top>
|
||||
<font color=#82A9D9><table cellspacing=0 cellpadding=0 border=0>
|
||||
<TR><TD maxlines="1">
|
||||
${address}
|
||||
</TD></TR>
|
||||
</TABLE></font>
|
||||
<font color=#82A9D9>(${userdisplayname})</font>
|
||||
<tr>
|
||||
<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>
|
||||
<td width=305 valign=top>
|
||||
<textarea
|
||||
bgcolor="#1F2033"
|
||||
cursor=#BDA73A
|
||||
nosoftbreaks
|
||||
borderimage="file://ROM/Borders/textfield.alt1.bif"
|
||||
nohardbreaks
|
||||
selected
|
||||
font=proportional
|
||||
text=#82A9D9
|
||||
name="message_to"
|
||||
border=0
|
||||
width=305 rows=1
|
||||
growable
|
||||
autoactivate
|
||||
addresses
|
||||
autoascii
|
||||
nohighlight
|
||||
></textarea>
|
||||
<tr>
|
||||
<td height=13 valign=middle colspan=2>
|
||||
<img src="wtv-mail:/content/images/sendmail_panel_dots.gif" width=385 height=2>
|
||||
<tr>
|
||||
<td abswidth=83 valign=top align=right>
|
||||
<font color=#82A9D9>Subject: </font>
|
||||
<td width=305 valign=top>
|
||||
<textarea
|
||||
bgcolor="#1F2033"
|
||||
cursor=#BDA73A
|
||||
nosoftbreaks
|
||||
borderimage="file://ROM/Borders/textfield.alt1.bif"
|
||||
nohardbreaks
|
||||
text=#82A9D9
|
||||
name="message_subject" font=proportional
|
||||
border=0
|
||||
width=305 rows=1
|
||||
growable
|
||||
autoactivate
|
||||
maxlength=70
|
||||
nohighlight
|
||||
autohiragana
|
||||
></textarea>
|
||||
<tr>
|
||||
<td height=13 valign=middle colspan=2>
|
||||
<img src="wtv-mail:/content/images/sendmail_panel_dots.gif" width=385 height=2>
|
||||
<tr>
|
||||
<td width=305 colspan=2>
|
||||
<textarea nosoftbreaks
|
||||
bgcolor="#1F2033"
|
||||
text=#82A9D9
|
||||
cursor=#BDA73A
|
||||
name="message_body" font=proportional
|
||||
border=0
|
||||
rows=4
|
||||
width=386
|
||||
nohighlight
|
||||
autoactivate
|
||||
autohiragana
|
||||
growable
|
||||
nextdown="Send"></textarea>
|
||||
</table>
|
||||
<body bgcolor=#1F2033
|
||||
text=#82A9D9
|
||||
link=#BDA73A
|
||||
vlink=#62B362
|
||||
vspace=0
|
||||
hspace=0>`;
|
||||
if (!ssid_sessions[socket.ssid].getSessionData("subscriber_signature") || ssid_sessions[socket.ssid].getSessionData("subscriber_signature") == "") {
|
||||
data += `<input type=hidden name="no_signature" value="true"> <td abswidth=13>`;
|
||||
} else {
|
||||
data += `<input type=checkbox name="no_signature"> <td abswidth=13> Disable Signature`;
|
||||
}
|
||||
data += `
|
||||
<td abswidth=2 bgcolor=#000000>
|
||||
<tr>
|
||||
<td abswidth=2 bgcolor=#495360>
|
||||
<td absheight=13 colspan=3>
|
||||
<td abswidth=2 bgcolor=#000000>
|
||||
<tr>
|
||||
<td absheight=2 colspan=5 bgcolor=#000000>
|
||||
</table>
|
||||
<tr>
|
||||
<td width=13 bgcolor=#171726>
|
||||
<td width=438 bgcolor=#171726>
|
||||
<spacer type=vertical size=5><br>
|
||||
<table cellspacing=0 cellpadding=0 border=0>
|
||||
<tr>
|
||||
<td width=305 valign=top>
|
||||
<td align=right valign=top width=110> <FONT COLOR="#E7CE4A"><SHADOW>
|
||||
<INPUT TYPE=SUBMIT BORDERIMAGE="file://ROM/Borders/ButtonBorder2.bif" action="javascript:Submit()"
|
||||
value="Send"
|
||||
name="Send"
|
||||
id="Send"
|
||||
xnocancel
|
||||
width=103
|
||||
USESTYLE NOARGS>
|
||||
</SHADOW></FONT>
|
||||
</table>
|
||||
<spacer type=vertical size=5>
|
||||
</form>
|
||||
</table>
|
||||
</body>
|
||||
</HTML>
|
||||
`;
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var WTVBGMusic = require("./WTVBGMusic.js");
|
||||
var wtvbgm = new WTVBGMusic(minisrv_config, ssid_sessions[socket.ssid])
|
||||
var music_obj = wtvbgm.getMusicObj();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var settings_obj = ssid_sessions[socket.ssid].getSessionData("wtv-setup");
|
||||
if (settings_obj === null) settings_obj = {};
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var music_obj = {};
|
||||
ssid_sessions[socket.ssid].setSessionData("wtv-bgmusic", music_obj);
|
||||
ssid_sessions[socket.ssid].saveSessionData();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
if (request_headers.query && ssid_sessions[socket.ssid]) {
|
||||
var settings_obj = ssid_sessions[socket.ssid].getSessionData("wtv-setup");
|
||||
if (settings_obj === null) settings_obj = {};
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
if (request_headers.query && ssid_sessions[socket.ssid]) {
|
||||
|
||||
if (request_headers.request_url.indexOf('?') >= 0) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
if (request_headers.query && ssid_sessions[socket.ssid]) {
|
||||
ssid_sessions[socket.ssid].setSessionData("subscriber_signature", (request_headers.query.mail_signature) ? request_headers.query.mail_signature : "");
|
||||
ssid_sessions[socket.ssid].saveSessionData();
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
if (request_headers.query) {
|
||||
if (request_headers.query.shade) {
|
||||
headers = `300 OK
|
||||
|
||||
@@ -388,11 +388,13 @@ class WTVClientSessionData {
|
||||
if (key === null) throw ("ClientSessionData.set(): invalid key provided");
|
||||
if (typeof (this.session_store) === 'undefined') this.session_store = new Array();
|
||||
this.session_store[key] = value;
|
||||
this.SaveIfRegistered();
|
||||
}
|
||||
|
||||
deleteSessionData(key) {
|
||||
if (key === null) throw ("ClientSessionData.delete(): invalid key provided");
|
||||
delete this.session_store[key];
|
||||
this.SaveIfRegistered();
|
||||
}
|
||||
|
||||
|
||||
@@ -407,11 +409,13 @@ class WTVClientSessionData {
|
||||
if (key === null) throw ("ClientSessionData.set(): invalid key provided");
|
||||
if (typeof (this.data_store) === 'undefined') this.data_store = new Array();
|
||||
this.data_store[key] = value;
|
||||
this.SaveIfRegistered();
|
||||
}
|
||||
|
||||
delete(key) {
|
||||
if (key === null) throw ("ClientSessionData.delete(): invalid key provided");
|
||||
delete this.data_store[key];
|
||||
this.SaveIfRegistered();
|
||||
}
|
||||
|
||||
getBoxName() {
|
||||
|
||||
@@ -13,18 +13,20 @@ class WTVMail {
|
||||
wtvshared = null;
|
||||
wtvmime = null;
|
||||
wtvclient = null;
|
||||
WTVClientSessionData = null;
|
||||
mailstore_dir = null;
|
||||
is_guest = null;
|
||||
mailboxes = null;
|
||||
|
||||
constructor(minisrv_config, ssid, WTVClientSessionData) {
|
||||
constructor(minisrv_config, ssid, wtvclient) {
|
||||
if (!minisrv_config) throw ("minisrv_config required");
|
||||
var WTVShared = require('./WTVShared.js')['WTVShared'];
|
||||
var WTVMime = require('./WTVMime.js');
|
||||
var WTVClientSessionData = require('./WTVClientSessionData.js');
|
||||
this.minisrv_config = minisrv_config;
|
||||
this.wtvshared = new WTVShared(minisrv_config);
|
||||
this.wtvmime = new WTVMime(minisrv_config);
|
||||
this.wtvclient = WTVClientSessionData;
|
||||
this.wtvclient = wtvclient;
|
||||
this.is_guest = !this.wtvclient.isRegistered();
|
||||
this.ssid = ssid;
|
||||
this.unread_mail = this.wtvclient.getSessionData("subscriber_unread_mail") ? this.wtvclient.getSessionData("subscriber_unread_mail") : 0;
|
||||
@@ -37,6 +39,15 @@ class WTVMail {
|
||||
];
|
||||
}
|
||||
|
||||
checkMailIntroSeen() {
|
||||
return (this.wtvclient.getSessionData("subscriber_mail_intro_seen")) ? this.wtvclient.getSessionData("subscriber_mail_intro_seen") : false;
|
||||
}
|
||||
|
||||
setMailIntroSeen(seen) {
|
||||
this.wtvclient.setSessionData("subscriber_mail_intro_seen", (seen) ? true : false);
|
||||
}
|
||||
|
||||
|
||||
mailstoreExists() {
|
||||
if (!this.isguest) {
|
||||
if (this.mailstore_dir === null) {
|
||||
@@ -102,7 +113,7 @@ class WTVMail {
|
||||
}
|
||||
|
||||
|
||||
createMessage(mailboxid, from_addr, to_addr, msgbody, subject = null, from_name = null, to_name = null, date = null, known_sender = false) {
|
||||
createMessage(mailboxid, from_addr, to_addr, msgbody, subject = null, from_name = null, to_name = null, signature = null, date = null, known_sender = false) {
|
||||
if (this.createMailbox(mailboxid)) {
|
||||
if (!date) date = Math.floor(Date.now() / 1000);
|
||||
|
||||
@@ -117,7 +128,8 @@ class WTVMail {
|
||||
"date": date,
|
||||
"subject": subject,
|
||||
"body": msgbody,
|
||||
"known_sender": known_sender
|
||||
"known_sender": known_sender,
|
||||
"signature": signature
|
||||
}
|
||||
try {
|
||||
if (this.fs.existsSync(message_file_out)) {
|
||||
@@ -149,7 +161,7 @@ class WTVMail {
|
||||
var to_name = this.wtvclient.getSessionData("subscriber_name");
|
||||
var subj = "Welcome to " + this.minisrv_config.config.service_name;
|
||||
var msg = "poop";
|
||||
return this.createMessage(0, from_addr, to_addr, msg, subj, from_name, to_name, null, true);
|
||||
return this.createMessage(0, from_addr, to_addr, msg, subj, from_name, to_name, null, null, true);
|
||||
}
|
||||
|
||||
getMessage(mailboxid, messageid) {
|
||||
@@ -174,6 +186,11 @@ class WTVMail {
|
||||
return false;
|
||||
}
|
||||
|
||||
checkMessageIdSanity(messageid) {
|
||||
return /^[A-Za-z0-9\-]{36}$/.test(messageid);
|
||||
}
|
||||
|
||||
|
||||
listMessages(mailboxid, limit, reverse_sort = false, offset = 0) {
|
||||
if (this.createMailbox(mailboxid)) {
|
||||
var mailbox_path = this.getMailboxStoreDir(mailboxid);
|
||||
@@ -212,6 +229,116 @@ class WTVMail {
|
||||
var messages = this.listMessages(mailboxid, false);
|
||||
return (messages.length) ? messages.length : 0;
|
||||
}
|
||||
|
||||
getMailboxIcon() {
|
||||
var icon_image = null;
|
||||
switch (this.countMessages(0)) {
|
||||
case 0:
|
||||
icon_image = "OpenMailbox0.gif";
|
||||
break;
|
||||
case 1:
|
||||
icon_image = "OpenMailbox1.gif";
|
||||
break;
|
||||
default:
|
||||
icon_image = "OpenMailbox2.gif";
|
||||
break;
|
||||
}
|
||||
return icon_image;
|
||||
}
|
||||
|
||||
checkUserExists(username) {
|
||||
// returns the user's SSID if true, false if not
|
||||
var username_match = false;
|
||||
var return_val = false;
|
||||
this.fs.readdirSync(this.minisrv_config.config.SessionStore).forEach(file => {
|
||||
if (!file.match(/.*\.json/ig)) return;
|
||||
if (username_match) return;
|
||||
try {
|
||||
var temp_session_data_file = this.fs.readFileSync(this.minisrv_config.config.SessionStore + this.path.sep + file, 'Utf8');
|
||||
var temp_session_data = JSON.parse(temp_session_data_file);
|
||||
if (temp_session_data.subscriber_username.toLowerCase() == username.toLowerCase()) return_val = temp_session_data.subscriber_username;
|
||||
} catch (e) {
|
||||
console.error(" # Error parsing Session Data JSON", file, e);
|
||||
}
|
||||
});
|
||||
return return_val;
|
||||
}
|
||||
|
||||
getUserMailstore(username) {
|
||||
var ssid = this.checkUserExists(username);
|
||||
if (ssid) {
|
||||
var user_wtvsession = new this.WTVClientSessionData(this.minisrv_config, ssid);
|
||||
var user_mailstore = new WTVMail(this.minisrv_config, ssid, user_wtvsession)
|
||||
return user_mailstore;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
sendMessageToAddr(from_addr, to_addr, msgbody, subject = null, from_name = null, to_name = null, signature = null) {
|
||||
if (!to_addr.indexOf('@')) {
|
||||
return "The m-mail address <strong>" + to_addr + "</strong> is not a valid m-mail address.<br><br>An m-mail address should look like:<br>: <strong>zefie@ZefieTV</strong>";
|
||||
}
|
||||
var username = to_addr.split("@")[0];
|
||||
var dest_minisrv = to_addr.split("@")[1];
|
||||
|
||||
// local only for now
|
||||
if (dest_minisrv.toLowerCase() !== this.minisrv_config.config.service_name.toLowerCase()) {
|
||||
return "The m-mail address <strong>" + to_addr + "</strong> is not supported by this MiniSrv.";
|
||||
}
|
||||
|
||||
// find user if local
|
||||
if (dest_minisrv.toLowerCase() === this.minisrv_config.config.service_name.toLowerCase()) {
|
||||
var dest_user_mailstore = getUserMailstore(to_addr);
|
||||
// user does not exist
|
||||
if (!dest_user_mailstore) return "The user <strong>" + username + "</strong> does not exist on MiniSrv <strong>" + dest_minisrv + "</strong>";
|
||||
|
||||
// check if the destination user's Inbox exists yet
|
||||
if (!dest_user_mailstore.mailboxExists(0)) {
|
||||
// mailbox does not yet exist, create it
|
||||
var mailbox_exists = dest_user_mailstore.createMailbox(mailbox);
|
||||
// Just created Inbox for the first time, so create the welcome message
|
||||
if (mailbox_exists) dest_user_mailstore.createWelcomeMessage();
|
||||
}
|
||||
// if the mailbox exists, deliver the message
|
||||
if (dest_user_mailstore.mailboxExists(0)) createMessage(0, from_addr, to_addr, msgbody, subject, from_name, to_name, signature);
|
||||
else return "There was an internal error sending the message to <strong>" + to_addr + "</strong>. Please try again later";
|
||||
|
||||
// clean up
|
||||
dest_user_mailstore = null;
|
||||
return true;
|
||||
}
|
||||
return "Unknown error";
|
||||
}
|
||||
|
||||
getMessageMailboxId(messageid) {
|
||||
// returns the mailbox id of which the message was found for the current user
|
||||
var self = this;
|
||||
var mailboxid = false;
|
||||
if (this.checkMessageIdSanity(messageid)) {
|
||||
if (this.mailstoreExists()) {
|
||||
this.fs.readdirSync(this.mailstore_dir).forEach(mailbox => {
|
||||
if (mailboxid) return;
|
||||
this.fs.readdirSync(this.mailstore_dir + self.path.sep + mailbox).forEach(file => {
|
||||
if (!file.match(/.*\.zmsg/ig)) return;
|
||||
if (mailboxid) return;
|
||||
if (file.indexOf(messageid) !== -1) mailboxid = mailbox;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
return mailboxid;
|
||||
}
|
||||
|
||||
getMessageByID(messageid) {
|
||||
var mailbox_name = this.getMessageMailboxId(messageid);
|
||||
if (!mailbox_name) return false;
|
||||
|
||||
var mailboxid = this.mailboxes.findIndex((value) => value == mailbox_name);
|
||||
|
||||
if (mailboxid !== false) return this.getMessage(mailboxid, messageid);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = WTVMail;
|
||||
|
||||
@@ -36,7 +36,7 @@ class WTVRegister {
|
||||
try {
|
||||
var temp_session_data_file = this.fs.readFileSync(this.session_store_dir + this.path.sep + file, 'Utf8');
|
||||
var temp_session_data = JSON.parse(temp_session_data_file);
|
||||
if (temp_session_data.subscriber_username == username) username_match = true;
|
||||
if (temp_session_data.subscriber_username.toLowerCase() == username.toLowerCase()) username_match = true;
|
||||
} catch (e) {
|
||||
console.error(" # Error parsing Session Data JSON", file, e);
|
||||
username_match = true;
|
||||
|
||||
@@ -273,6 +273,10 @@ class WTVShared {
|
||||
return this.fixPathSlashes(base + this.path.sep + targetPath);
|
||||
}
|
||||
|
||||
makeSafeUsername(username) {
|
||||
return username.replace(/^([A-Za-z0-9\-\_]{5,16})$/, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Corrects any / or \ differences, if any for file paths
|
||||
* @param {string} path
|
||||
|
||||
@@ -6,16 +6,17 @@ const zlib = require('zlib');
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const strftime = require('strftime'); // used externally by service scripts
|
||||
const html_entities = require('html-entities'); // used externally by service scripts
|
||||
const net = require('net');
|
||||
const CryptoJS = require('crypto-js');
|
||||
const { crc16 } = require('easy-crc');
|
||||
const process = require('process');
|
||||
var WTVSec = require('./WTVSec.js');
|
||||
var WTVLzpf = require('./WTVLzpf.js');
|
||||
var WTVClientCapabilities = require('./WTVClientCapabilities.js');
|
||||
var WTVClientSessionData = require('./WTVClientSessionData.js');
|
||||
var WTVMime = require("./WTVMime.js");
|
||||
var { WTVShared, clientShowAlert } = require("./WTVShared.js");
|
||||
const WTVSec = require('./WTVSec.js');
|
||||
const WTVLzpf = require('./WTVLzpf.js');
|
||||
const WTVClientCapabilities = require('./WTVClientCapabilities.js');
|
||||
const WTVClientSessionData = require('./WTVClientSessionData.js');
|
||||
const WTVMime = require("./WTVMime.js");
|
||||
const { WTVShared, clientShowAlert } = require("./WTVShared.js");
|
||||
|
||||
process
|
||||
.on('SIGTERM', shutdown('SIGTERM'))
|
||||
|
||||
11
zefie_wtvp_minisrv/package-lock.json
generated
11
zefie_wtvp_minisrv/package-lock.json
generated
@@ -12,6 +12,7 @@
|
||||
"crypto-js": "^4.1.1",
|
||||
"easy-crc": "0.0.2",
|
||||
"endianness": "^8.0.2",
|
||||
"html-entities": "^2.3.2",
|
||||
"mime-types": "^2.1.33",
|
||||
"proxy-agent": "^5.0.0",
|
||||
"strftime": "^0.10.0",
|
||||
@@ -242,6 +243,11 @@
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz",
|
||||
"integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg=="
|
||||
},
|
||||
"node_modules/html-entities": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.2.tgz",
|
||||
"integrity": "sha512-c3Ab/url5ksaT0WyleslpBEthOzWhrjQbg75y7XUsfSzi3Dgzt0l8w5e7DylRn15MTlMMD58dTfzddNS2kcAjQ=="
|
||||
},
|
||||
"node_modules/http-errors": {
|
||||
"version": "1.7.3",
|
||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz",
|
||||
@@ -783,6 +789,11 @@
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz",
|
||||
"integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg=="
|
||||
},
|
||||
"html-entities": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.2.tgz",
|
||||
"integrity": "sha512-c3Ab/url5ksaT0WyleslpBEthOzWhrjQbg75y7XUsfSzi3Dgzt0l8w5e7DylRn15MTlMMD58dTfzddNS2kcAjQ=="
|
||||
},
|
||||
"http-errors": {
|
||||
"version": "1.7.3",
|
||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz",
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
"crypto-js": "^4.1.1",
|
||||
"easy-crc": "0.0.2",
|
||||
"endianness": "^8.0.2",
|
||||
"html-entities": "^2.3.2",
|
||||
"mime-types": "^2.1.33",
|
||||
"proxy-agent": "^5.0.0",
|
||||
"strftime": "^0.10.0",
|
||||
|
||||
@@ -95,6 +95,12 @@
|
||||
<Content Include="ServiceVault\wtv-mail\listmail.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="ServiceVault\wtv-mail\readmail.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="ServiceVault\wtv-mail\sendmail.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="ServiceVault\wtv-music\demo\hacktv4.gif" />
|
||||
<Content Include="ServiceVault\wtv-music\demo\index.html" />
|
||||
<Content Include="ServiceVault\wtv-music\demo\midi\acey.mid" />
|
||||
|
||||
Reference in New Issue
Block a user