fix/optimize mailto, news, wtv-1800

This commit is contained in:
zefie
2025-08-12 18:10:20 -04:00
parent 5ae47352ed
commit b9d64de79e
6 changed files with 40 additions and 45 deletions

View File

@@ -1,10 +1,10 @@
var minisrv_service_file = true; const minisrv_service_file = true;
var mailto = request_headers.request_url; let mailto = request_headers.request_url;
mailto = mailto.slice(mailto.indexOf(":") + 1); mailto = mailto.slice(mailto.indexOf(":") + 1);
mailto = mailto.split("?")[0]; mailto = mailto.split("?")[0];
var subject = request_headers.query.subject || ""; const subject = request_headers.query.subject || "";
var body = request_headers.query.body || ""; const body = request_headers.query.body || "";
session_data.deleteSessionData("mail_draft"); session_data.deleteSessionData("mail_draft");
session_data.deleteSessionData("mail_draft_attachments"); session_data.deleteSessionData("mail_draft_attachments");

View File

@@ -1,5 +1,5 @@
var minisrv_service_file = true; const minisrv_service_file = true;
var dest_url = "wtv-news:/news?group=" + request_headers.request_url.split(":")[1]; const dest_url = "wtv-news:/news?group=" + request_headers.request_url.split(":")[1];
headers = `300 Moved headers = `300 Moved
Location: ${dest_url}` Location: ${dest_url}`

View File

@@ -1,17 +1,16 @@
var minisrv_service_file = true; const minisrv_service_file = true;
let wtvsec_login;
if (socket.ssid != null && !session_data.get("wtvsec_login")) { if (socket.ssid != null && !session_data.get("wtvsec_login")) {
var wtvsec_login = session_data.createWTVSecSession(); wtvsec_login = session_data.createWTVSecSession();
wtvsec_login.IssueChallenge(); wtvsec_login.IssueChallenge();
if (request_headers["wtv-incarnation"]) wtvsec_login.set_incarnation(request_headers["wtv-incarnation"]); if (request_headers["wtv-incarnation"]) wtvsec_login.set_incarnation(request_headers["wtv-incarnation"]);
session_data.set("wtvsec_login", wtvsec_login); session_data.set("wtvsec_login", wtvsec_login);
} else if (socket.ssid != null) { } else if (socket.ssid != null) {
var wtvsec_login = session_data.get("wtvsec_login"); wtvsec_login = session_data.get("wtvsec_login");
} }
if (wtvsec_login) { if (wtvsec_login) {
headers = `200 OK headers = `200 OK
Connection: Keep-Alive Connection: Keep-Alive
minisrv-no-mail-count: true minisrv-no-mail-count: true
@@ -28,7 +27,7 @@ wtv-client-time-zone: GMT -0000
wtv-client-time-dst-rule: GMT wtv-client-time-dst-rule: GMT
wtv-client-date: `+ strftime("%a, %d %b %Y %H:%M:%S", new Date(new Date().toUTCString())) + ` GMT`; wtv-client-date: `+ strftime("%a, %d %b %Y %H:%M:%S", new Date(new Date().toUTCString())) + ` GMT`;
var file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app_WTV_18006138199.tok", true); const file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app_WTV_18006138199.tok", true);
if (file_path) { if (file_path) {
request_is_async = true; request_is_async = true;
@@ -41,7 +40,7 @@ wtv-client-date: `+ strftime("%a, %d %b %Y %H:%M:%S", new Date(new Date().toUTCS
} }
} else { } else {
console.log(" * Something bad happened (we don't know the client ssid???)"); console.log(" * Something bad happened (we don't know the client ssid???)");
headers=`500 missing ssid` headers = '500 missing ssid';
} }

View File

@@ -1,6 +1,6 @@
var minisrv_service_file = true; const minisrv_service_file = true;
var gourl = "wtv-1800:/finish-prereg?"; let gourl = "wtv-1800:/finish-prereg?";
if (request_headers.query.relogin) gourl += "relogin=true"; if (request_headers.query.relogin) gourl += "relogin=true";

View File

@@ -1,8 +1,6 @@
var minisrv_service_file = true; const minisrv_service_file = true;
let gourl = "wtv-head-waiter:/login?";
let file_path = null;
var gourl = "wtv-head-waiter:/login?";
if (session_data) { if (session_data) {
if (session_data.loadSessionData() == true) { if (session_data.loadSessionData() == true) {
@@ -14,7 +12,7 @@ if (session_data) {
} }
if (session_data.data_store) { if (session_data.data_store) {
if (session_data.data_store.sockets) { if (session_data.data_store.sockets) {
var i = 0; let i = 0;
session_data.data_store.sockets.forEach(function (k) { session_data.data_store.sockets.forEach(function (k) {
if (typeof k != "undefined") { if (typeof k != "undefined") {
if (k != socket) { if (k != socket) {
@@ -37,7 +35,7 @@ if (session_data) {
if (request_headers["wtv-incarnation"]) session_data.data_store.wtvsec_login.set_incarnation(request_headers["wtv-incarnation"]); if (request_headers["wtv-incarnation"]) session_data.data_store.wtvsec_login.set_incarnation(request_headers["wtv-incarnation"]);
} else { } else {
console.log(" * Something bad happened (we don't know the client ssid???)"); console.log(" * Something bad happened (we don't know the client ssid???)");
var errpage = wtvshared.doErrorPage(400) const errpage = wtvshared.doErrorPage(400)
headers = errpage[0]; headers = errpage[0];
data = errpage[1]; data = errpage[1];
} }
@@ -49,19 +47,18 @@ if (request_headers.query.relogin && session_data.getSessionData("registered"))
if (request_headers.query.reconnect && session_data.getSessionData("registered")) gourl += "reconnect=true"; if (request_headers.query.reconnect && session_data.getSessionData("registered")) gourl += "reconnect=true";
if (session_data.data_store.wtvsec_login) { if (session_data.data_store.wtvsec_login) {
var prereg_contype = "text/html"; let prereg_contype = "text/html";
// if relogin and wtv-script-id != 0, skip tellyscript // if relogin and wtv-script-id != 0, skip tellyscript
session_data.set("wtv-open-access", (request_headers['wtv-open-access'] === "true") ? true : false); session_data.set("wtv-open-access", (request_headers['wtv-open-access'] === "true") ? true : false);
var file_path = null; let template = null;
var template = null; const template_preprocessor = {};
var template_preprocessor = {}; let bf0app_update = false;
var bf0app_update = false; const romtype = session_data.get("wtv-client-rom-type");
var romtype = session_data.get("wtv-client-rom-type"); const bootrom = parseInt(session_data.get("wtv-client-bootrom-version"));
var bootrom = parseInt(session_data.get("wtv-client-bootrom-version")); let send_tellyscript = (minisrv_config.services[service_name].send_tellyscripts && !request_headers.query.relogin && !bootrom !== 0);
var send_tellyscript = (minisrv_config.services[service_name].send_tellyscripts && !request_headers.query.relogin && !bootrom !== 0); const wtv_script_id = parseInt(session_data.get("wtv-script-id"));
var wtv_script_id = parseInt(session_data.get("wtv-script-id")); const wtv_script_mod = parseInt(session_data.get("wtv-script-mod"));
var wtv_script_mod = parseInt(session_data.get("wtv-script-mod"));
if ((request_headers.query.reconnect || request_headers.query.relogin) && wtv_script_id != 0) send_tellyscript = false; if ((request_headers.query.reconnect || request_headers.query.relogin) && wtv_script_id != 0) send_tellyscript = false;
if (wtv_script_id !== 0 && wtv_script_mod !== 0) send_tellyscript = false; if (wtv_script_id !== 0 && wtv_script_mod !== 0) send_tellyscript = false;
if (!minisrv_config.services[service_name].send_tellyscript_to_mame) { if (!minisrv_config.services[service_name].send_tellyscript_to_mame) {
@@ -75,7 +72,6 @@ if (session_data.data_store.wtvsec_login) {
} }
if (send_tellyscript) { if (send_tellyscript) {
romtype = session_data.get("wtv-client-rom-type");
switch (romtype) { switch (romtype) {
case "US-LC2-disk-0MB-8MB": case "US-LC2-disk-0MB-8MB":
case "US-LC2-disk-0MB-8MB-softmodem-CPU5230": case "US-LC2-disk-0MB-8MB-softmodem-CPU5230":
@@ -118,7 +114,7 @@ if (session_data.data_store.wtvsec_login) {
prereg_contype = "text/tellyscript"; prereg_contype = "text/tellyscript";
// if wtv-open-access: true then client expects OpenISP // if wtv-open-access: true then client expects OpenISP
template = wtvshared.getServiceDep("/wtv-1800/tellyscripts/base.template.tsf") template = wtvshared.getServiceDep("/wtv-1800/tellyscripts/base.template.tsf")
template_preprocessor = { 'CLASSIC': true } template_preprocessor.CLASSIC = true;
if (session_data.get("wtv-open-access")) template += wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app.openisp.template.tsf"); if (session_data.get("wtv-open-access")) template += wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app.openisp.template.tsf");
else template += wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app.normal.template.tsf"); else template += wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app.normal.template.tsf");
//else file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app_WTV_18006138199.tok", true); //else file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app_WTV_18006138199.tok", true);
@@ -128,10 +124,10 @@ if (session_data.data_store.wtvsec_login) {
case "JP-Fiji": case "JP-Fiji":
prereg_contype = "text/tellyscript"; prereg_contype = "text/tellyscript";
template_preprocessor = { 'FIJI': true } template_preprocessor.FIJI = true;
// if wtv-open-access: true then client expects OpenISP // if wtv-open-access: true then client expects OpenISP
if (session_data.get("wtv-open-access")) var file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/FIJI/dc_production_normal.tok", true); if (session_data.get("wtv-open-access")) file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/FIJI/dc_production_normal.tok", true);
else var file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/FIJI/dc_production_normal.tok", true); else file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/FIJI/dc_production_normal.tok", true);
break; break;
default: default:
@@ -141,7 +137,7 @@ if (session_data.data_store.wtvsec_login) {
if (socket.ssid.slice(0, 8) === "MSTVSIMU") { if (socket.ssid.slice(0, 8) === "MSTVSIMU") {
prereg_contype = "text/dialscript"; prereg_contype = "text/dialscript";
var file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/UTV/utv_hsd.tok", true); file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/UTV/utv_hsd.tok", true);
} }
} }
@@ -150,8 +146,8 @@ if (session_data.data_store.wtvsec_login) {
// assume old classic in flash mode, override user setting and send tellyscript // assume old classic in flash mode, override user setting and send tellyscript
// because it is required to proceed in flash mode // because it is required to proceed in flash mode
prereg_contype = "text/tellyscript"; prereg_contype = "text/tellyscript";
var file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app_WTV_18006138199.tok", true); file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app_WTV_18006138199.tok", true);
var bf0app_update = true; bf0app_update = true;
session_data.set("bf0app_update", bf0app_update); session_data.set("bf0app_update", bf0app_update);
} }
@@ -197,7 +193,7 @@ if (session_data.data_store.wtvsec_login) {
request_is_async = true; request_is_async = true;
fs.readFile(file_path, null, function (err, file_read_data) { fs.readFile(file_path, null, function (err, file_read_data) {
if (err) { if (err) {
var errmsg = wtvshared.doErrorPage(400); const errmsg = wtvshared.doErrorPage(400);
headers = errmsg[0]; headers = errmsg[0];
file_read_data = errmsg[1] + "\n" + err.toString(); file_read_data = errmsg[1] + "\n" + err.toString();
} }
@@ -205,7 +201,7 @@ if (session_data.data_store.wtvsec_login) {
}); });
} else if (template) { } else if (template) {
request_is_async = true; request_is_async = true;
telly = new WTVTellyScript(template, 2, template_preprocessor, session_data.get("wtv-open-access") ? 3 : 1); // dataState 2 = Untokenized const telly = new WTVTellyScript(template, 2, template_preprocessor, session_data.get("wtv-open-access") ? 3 : 1); // dataState 2 = Untokenized
telly.setTemplateVars(minisrv_config.config.service_name, minisrv_config.services[service_name].dialin_number, minisrv_config.services[service_name].dns1ip, minisrv_config.services[service_name].dns2ip); telly.setTemplateVars(minisrv_config.config.service_name, minisrv_config.services[service_name].dialin_number, minisrv_config.services[service_name].dns1ip, minisrv_config.services[service_name].dns2ip);
telly.minify(); telly.minify();
telly.tokenize(); telly.tokenize();
@@ -213,7 +209,7 @@ if (session_data.data_store.wtvsec_login) {
sendToClient(socket, headers, telly.packed_data); sendToClient(socket, headers, telly.packed_data);
} }
} else { } else {
var errpage = wtvshared.doErrorPage(400); const errpage = wtvshared.doErrorPage(400);
headers = errpage[0]; headers = errpage[0];
data = errpage[1]; data = errpage[1];
} }

View File

@@ -1,4 +1,4 @@
var minisrv_service_file = true; const minisrv_service_file = true;
headers = `200 OK headers = `200 OK
Content-type: text/html Content-type: text/html