more optimizations, remove WTVIRC for now, upgrade test.js
This commit is contained in:
@@ -51,7 +51,7 @@ class WTVAdmin {
|
||||
* @returns {number} The result of the ban operation
|
||||
*/
|
||||
banSSID(ssid, admin_ssid = null) {
|
||||
if (ssid == admin_ssid) {
|
||||
if (ssid === admin_ssid) {
|
||||
return this.REASON_NOSELF;
|
||||
} else {
|
||||
const fake_config = this.wtvshared.getUserConfig();
|
||||
@@ -60,7 +60,7 @@ class WTVAdmin {
|
||||
let entry_exists = false;
|
||||
const self = this;
|
||||
Object.keys(fake_config.config.ssid_block_list).forEach(function (k) {
|
||||
if (fake_config.config.ssid_block_list[k] == ssid) {
|
||||
if (fake_config.config.ssid_block_list[k] === ssid) {
|
||||
entry_exists = true;
|
||||
return self.REASON_EXISTS;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class WTVAdmin {
|
||||
if (!fake_config.config.ssid_block_list) fake_config.config.ssid_block_list = [];
|
||||
if (typeof ssid === 'string') {
|
||||
Object.keys(fake_config.config.ssid_block_list).forEach(function (k) {
|
||||
if (fake_config.config.ssid_block_list[k].toLowerCase() == ssid.toLowerCase()) {
|
||||
if (fake_config.config.ssid_block_list[k].toLowerCase() === ssid.toLowerCase()) {
|
||||
fake_config.config.ssid_block_list.splice(k, 1);
|
||||
config_changed = true
|
||||
}
|
||||
@@ -93,7 +93,7 @@ class WTVAdmin {
|
||||
} else {
|
||||
Object.keys(fake_config.config.ssid_block_list).forEach(function (k) {
|
||||
Object.keys(ssid).forEach(function (j) {
|
||||
if (fake_config.config.ssid_block_list[k].toLowerCase() == ssid[j].toLowerCase()) {
|
||||
if (fake_config.config.ssid_block_list[k].toLowerCase() === ssid[j].toLowerCase()) {
|
||||
fake_config.config.ssid_block_list.splice(k, 1);
|
||||
config_changed = true
|
||||
}
|
||||
@@ -139,14 +139,14 @@ class WTVAdmin {
|
||||
checkPassword(password) {
|
||||
if (this.pcservices) {
|
||||
if (this.minisrv_config.config.pc_admin.password) {
|
||||
return (password == this.minisrv_config.config.pc_admin.password);
|
||||
return (password === this.minisrv_config.config.pc_admin.password);
|
||||
} else {
|
||||
// no password set
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (this.minisrv_config.services[this.service_name].password) {
|
||||
return (password == this.minisrv_config.services[this.service_name].password);
|
||||
return (password === this.minisrv_config.services[this.service_name].password);
|
||||
} else {
|
||||
// no password set
|
||||
return true;
|
||||
@@ -184,13 +184,13 @@ class WTVAdmin {
|
||||
if (this.minisrv_config.services[this.service_name].authorized_ssids) {
|
||||
const self = this;
|
||||
Object.keys(self.minisrv_config.services[this.service_name].authorized_ssids).forEach(function (k) {
|
||||
if (typeof self.minisrv_config.services[self.service_name].authorized_ssids[k] == "string") {
|
||||
if (typeof self.minisrv_config.services[self.service_name].authorized_ssids[k] === "string") {
|
||||
const ssid = self.minisrv_config.services[self.service_name].authorized_ssids[k]
|
||||
if (ssid == self.wtvclient.ssid) allowed_ssid = true;
|
||||
if (ssid === self.wtvclient.ssid) allowed_ssid = true;
|
||||
allowed_ip = true; // no ip block defined
|
||||
} else {
|
||||
const ssid = k;
|
||||
if (ssid == self.wtvclient.ssid) {
|
||||
if (ssid === self.wtvclient.ssid) {
|
||||
allowed_ssid = true;
|
||||
Object.keys(self.minisrv_config.services[self.service_name].authorized_ssids[k]).forEach(function (j) {
|
||||
if (self.wtvshared.isInSubnet(self.clientAddress, self.minisrv_config.services[self.service_name].authorized_ssids[k][j])) {
|
||||
@@ -247,7 +247,7 @@ class WTVAdmin {
|
||||
const temp_session_data_file = self.fs.readFileSync(search_dir + self.path.sep + file, 'Utf8');
|
||||
const temp_session_data = JSON.parse(temp_session_data_file);
|
||||
|
||||
if (temp_session_data.subscriber_username.toLowerCase() == username.toLowerCase()) {
|
||||
if (temp_session_data.subscriber_username.toLowerCase() === username.toLowerCase()) {
|
||||
account_data = [temp_session_data, (search_dir + self.path.sep + file).replace(this.wtvshared.getAbsolutePath(this.minisrv_config.config.SessionStore + this.path.sep + "accounts"), "").split(this.path.sep)[1]];
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -317,7 +317,7 @@ class WTVAdmin {
|
||||
let isBanned = false;
|
||||
if (this.minisrv_config.config.ssid_block_list) {
|
||||
Object.keys(this.minisrv_config.config.ssid_block_list).forEach(function (k) {
|
||||
if (self.minisrv_config.config.ssid_block_list[k] == ssid) {
|
||||
if (self.minisrv_config.config.ssid_block_list[k] === ssid) {
|
||||
isBanned = true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -102,7 +102,7 @@ class WTVAuthor {
|
||||
this.debug("createPage", "pagenum", pagenum)
|
||||
this.debug("createPage", "pagelen", pagelen)
|
||||
}
|
||||
if (pages.length == 0) {
|
||||
if (pages.length === 0) {
|
||||
pagenum = 0
|
||||
pagefile = pagenum + this.pageFileExt;
|
||||
} else {
|
||||
@@ -130,7 +130,7 @@ class WTVAuthor {
|
||||
// Encode page data into JSON
|
||||
let returnval = pages.length
|
||||
this.fs.writeFileSync(pagefileout, JSON.stringify(pagedata));
|
||||
if (returnval != 0) {
|
||||
if (returnval !== 0) {
|
||||
const npages = this.fs.readdirSync(pagestorepath)
|
||||
returnval = npages.length - 1;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ class WTVAuthor {
|
||||
|
||||
case "snapshot":
|
||||
case "scrapbook":
|
||||
if (state == "publishing") {
|
||||
if (state === "publishing") {
|
||||
block = this.generatePublishImageBlock(number, page);
|
||||
} else {
|
||||
templatePath = this.wtvshared.getServiceDep('wtv-author/blocks/snapshot_block.njk', true);
|
||||
@@ -212,7 +212,7 @@ class WTVAuthor {
|
||||
break;
|
||||
|
||||
case "clipart":
|
||||
if (state == "publishing") {
|
||||
if (state === "publishing") {
|
||||
block = this.generatePublishImageBlock(number, page);
|
||||
} else {
|
||||
templatePath = this.wtvshared.getServiceDep('wtv-author/blocks/clipart_block.njk', true);
|
||||
@@ -296,35 +296,35 @@ class WTVAuthor {
|
||||
const pagedata = this.loadPage(pagenum);
|
||||
let title;
|
||||
// Should probably have a better way to know if the page has no title
|
||||
if (pagedata.title == "(Untitled)" && state == "editing")
|
||||
if (pagedata.title === "(Untitled)" && state === "editing")
|
||||
title = "<i>Choose this to add a title to your document</i>"
|
||||
else
|
||||
title = pagedata.title
|
||||
// Set the page style with too many paramaters
|
||||
this.setStyle(pagedata.style, title, pagedata.description, state, pagenum);
|
||||
let html = this.header
|
||||
if (page == 1) {
|
||||
if (pagedata.showtitle == true){
|
||||
if (page === 1) {
|
||||
if (pagedata.showtitle === true){
|
||||
html += this.titheader
|
||||
}
|
||||
}
|
||||
html += this.tabstart
|
||||
// This generates blocks on separate pages in the most neat and optimized way possible (i think, i hate past jar)
|
||||
if (page != 1) {
|
||||
if (page !== 1) {
|
||||
for (let i = pagedata.pagebreaks[page - 2]; i < (pagedata.pagebreaks[page - 1] || pagedata.blocks.length); i++) {
|
||||
html += this.generateBlock(i, pagenum, state)
|
||||
}
|
||||
} else if (pagedata.pagebreaks.length != 0){
|
||||
} else if (pagedata.pagebreaks.length !== 0){
|
||||
for (let i = 0; i < pagedata.pagebreaks[0]; i++) {
|
||||
html += this.generateBlock(i, pagenum, state)
|
||||
if (this.afterblock1 && i == 0) {
|
||||
if (this.afterblock1 && i === 0) {
|
||||
html += this.afterblock1
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < pagedata.blocks.length; i++) {
|
||||
html += this.generateBlock(i, pagenum, state)
|
||||
if (this.afterblock1 && i == 0) {
|
||||
if (this.afterblock1 && i === 0) {
|
||||
html += this.afterblock1
|
||||
}
|
||||
}
|
||||
@@ -345,7 +345,7 @@ class WTVAuthor {
|
||||
const pages = this.fs.readdirSync(pagestorepath)
|
||||
const page = pages[pagenum]
|
||||
const result = this.fs.writeFileSync(pagepath + page, JSON.stringify(pageout));
|
||||
if (pagedata.published == true && callPublish) {
|
||||
if (pagedata.published === true && callPublish) {
|
||||
this.publishPage(pagenum, pagedata.inlist, false)
|
||||
}
|
||||
if (!result) return false;
|
||||
@@ -402,7 +402,7 @@ class WTVAuthor {
|
||||
const blocks = pagedata.blocks;
|
||||
blocks.splice(position, 1);
|
||||
this.editPage(pagedata, pagenum);
|
||||
if (block.type == "break")
|
||||
if (block.type === "break")
|
||||
this.generateBreakList(pagenum)
|
||||
return true;
|
||||
}
|
||||
@@ -411,7 +411,7 @@ class WTVAuthor {
|
||||
if (this.minisrv_config.services['wtv-author'].public_domain) {
|
||||
return this.minisrv_config.services['wtv-author'].public_domain;
|
||||
} else {
|
||||
if (this.minisrv_config.services['wtv-author'].publish_mode == "service") {
|
||||
if (this.minisrv_config.services['wtv-author'].publish_mode === "service") {
|
||||
const target_service = this.minisrv_config.services[this.minisrv_config.services['wtv-author'].publish_dest];
|
||||
if (target_service) {
|
||||
return target_service.host + ":" + target_service.port;
|
||||
@@ -432,7 +432,7 @@ class WTVAuthor {
|
||||
|
||||
getPublishDir() {
|
||||
let destDir = false;
|
||||
if (this.minisrv_config.services['wtv-author'].publish_mode == "service") {
|
||||
if (this.minisrv_config.services['wtv-author'].publish_mode === "service") {
|
||||
const target_service = this.minisrv_config.services[this.minisrv_config.services['wtv-author'].publish_dest];
|
||||
if (target_service) {
|
||||
if (!target_service.pc_services) {
|
||||
@@ -448,7 +448,7 @@ class WTVAuthor {
|
||||
destDir = this.minisrv_config.config.ServiceVaults[0] + this.path.sep + target_service.servicevault_dir + this.path.sep;
|
||||
}
|
||||
}
|
||||
} else if (this.minisrv_config.services['wtv-author'].publish_mode == "directory") {
|
||||
} else if (this.minisrv_config.services['wtv-author'].publish_mode === "directory") {
|
||||
destDir = this.minisrv_config.services['wtv-author'].publish_dest;
|
||||
} else {
|
||||
console.error("Invalid service configuration: invalid publish_mode.");
|
||||
@@ -461,7 +461,7 @@ class WTVAuthor {
|
||||
unpublishPage(pagenum) {
|
||||
const pagedata = this.loadPage(pagenum)
|
||||
const destDir = this.getPublishDir();
|
||||
if (pagedata.published != true) {
|
||||
if (pagedata.published !== true) {
|
||||
return "This page is not published."
|
||||
}
|
||||
const publishname = pagedata.publishname;
|
||||
@@ -489,7 +489,7 @@ class WTVAuthor {
|
||||
const destDir = this.getPublishDir();
|
||||
let publishname, fileout;
|
||||
|
||||
if (pagedata.published != true) {
|
||||
if (pagedata.published !== true) {
|
||||
publishname = pagedata.title.slice(0, 50).replaceAll(" ", "").replace(/[^A-Za-z0-9]/g, "-");
|
||||
pagedata.publishname = publishname;
|
||||
this.editPage(pagedata, pagenum);
|
||||
@@ -505,7 +505,7 @@ class WTVAuthor {
|
||||
this.fs.mkdirSync(destDir + this.wtvclient.session_store.subscriber_username + '/' + publishname + "/media/", { recursive: true })
|
||||
for (let i = 1; i < pagedata.pagebreaks.length + 2; i++) {
|
||||
const pagehtml = this.generatePage("publishing", pagenum, i)
|
||||
if (i == 1)
|
||||
if (i === 1)
|
||||
fileout = "index.html"
|
||||
else
|
||||
fileout = "page" + i + ".html"
|
||||
@@ -613,8 +613,8 @@ class WTVAuthor {
|
||||
pagedata.blocks[oldposition].caption = caption
|
||||
pagedata.blocks[oldposition].size = size
|
||||
pagedata.blocks[oldposition].style = style
|
||||
|
||||
if (oldposition != position)
|
||||
|
||||
if (oldposition !== position)
|
||||
this.wtvshared.moveObjectKey(pagedata.blocks,oldposition,position);
|
||||
|
||||
this.editPage(pagedata, pagenum);
|
||||
@@ -646,22 +646,22 @@ class WTVAuthor {
|
||||
|
||||
const blocks = pagedata.blocks
|
||||
|
||||
if (photo != null) {
|
||||
if (photo !== null) {
|
||||
const base64photo = new Buffer.from(photo).toString('base64')
|
||||
blocks[oldposition].photo = base64photo
|
||||
}
|
||||
|
||||
if (type != null) {
|
||||
if (type !== null) {
|
||||
blocks[oldposition].type = type
|
||||
}
|
||||
|
||||
if (title != null)
|
||||
if (title !== null)
|
||||
blocks[oldposition].title = title
|
||||
|
||||
if (caption != null)
|
||||
if (caption !== null)
|
||||
blocks[oldposition].caption = caption
|
||||
|
||||
if (oldposition != position) {
|
||||
if (oldposition !== position) {
|
||||
this.wtvshared.moveObjectKey(blocks, oldposition,position);
|
||||
}
|
||||
|
||||
@@ -696,10 +696,10 @@ class WTVAuthor {
|
||||
pagedata.blocks[oldposition].size = size
|
||||
pagedata.blocks[oldposition].dividerBefore = dividerBefore
|
||||
pagedata.blocks[oldposition].dividerAfter = dividerAfter
|
||||
|
||||
if (oldposition != position)
|
||||
this.wtvshared.moveObjectKey(pagedata.blocks, oldposition,position);
|
||||
|
||||
|
||||
if (oldposition !== position)
|
||||
this.wtvshared.moveObjectKey(pagedata.blocks, oldposition, position);
|
||||
|
||||
this.editPage(pagedata, pagenum);
|
||||
return true;
|
||||
}
|
||||
@@ -727,10 +727,10 @@ class WTVAuthor {
|
||||
|
||||
pagedata.blocks[oldposition].title = title
|
||||
pagedata.blocks[oldposition].items = items
|
||||
|
||||
if (oldposition != position)
|
||||
this.wtvshared.moveObjectKey(pagedata.blocks,oldposition,position);
|
||||
|
||||
|
||||
if (oldposition !== position)
|
||||
this.wtvshared.moveObjectKey(pagedata.blocks, oldposition, position);
|
||||
|
||||
this.editPage(pagedata, pagenum);
|
||||
return true;
|
||||
}
|
||||
@@ -745,7 +745,7 @@ class WTVAuthor {
|
||||
const url = linkItems[i]
|
||||
const name = listItems[i]
|
||||
|
||||
if (url == "http://") {
|
||||
if (url === "http://") {
|
||||
continue loop;
|
||||
} else {
|
||||
const subblock = {
|
||||
@@ -778,8 +778,8 @@ class WTVAuthor {
|
||||
for (let i = 0; i < linkItems.length; i++) {
|
||||
const url = linkItems[i]
|
||||
const name = listItems[i]
|
||||
|
||||
if (url == "http://") {
|
||||
|
||||
if (url === "http://") {
|
||||
continue loop;
|
||||
} else {
|
||||
const subblock = {
|
||||
@@ -792,10 +792,10 @@ class WTVAuthor {
|
||||
|
||||
pagedata.blocks[oldposition].title = title
|
||||
pagedata.blocks[oldposition].items = items
|
||||
|
||||
if (oldposition != position)
|
||||
this.wtvshared.moveObjectKey(pagedata.blocks,oldposition,position);
|
||||
|
||||
|
||||
if (oldposition !== position)
|
||||
this.wtvshared.moveObjectKey(pagedata.blocks, oldposition, position);
|
||||
|
||||
this.editPage(pagedata, pagenum);
|
||||
return true;
|
||||
}
|
||||
@@ -818,10 +818,10 @@ class WTVAuthor {
|
||||
editBreakBlock(pagenum, position, oldposition) {
|
||||
const pagedata = this.loadPage(pagenum);
|
||||
if (!pagedata) return false;
|
||||
|
||||
if (oldposition != position)
|
||||
this.wtvshared.moveObjectKey(pagedata.blocks,oldposition,position);
|
||||
|
||||
|
||||
if (oldposition !== position)
|
||||
this.wtvshared.moveObjectKey(pagedata.blocks, oldposition, position);
|
||||
|
||||
this.editPage(pagedata, pagenum);
|
||||
this.generateBreakList(pagenum);
|
||||
return true;
|
||||
@@ -832,7 +832,7 @@ class WTVAuthor {
|
||||
const breaks = [];
|
||||
for (let i = 0; i < pagedata.blocks.length; i++) {
|
||||
const type = pagedata.blocks[i].type
|
||||
if (type == "break")
|
||||
if (type === "break")
|
||||
breaks.push(i)
|
||||
}
|
||||
pagedata.pagebreaks = breaks;
|
||||
|
||||
@@ -1259,9 +1259,9 @@ class WTVBGMusic {
|
||||
// check if we need to set defaults
|
||||
let setDefaults = force_default;
|
||||
if (!music_obj.enableCategories) setDefaults = true;
|
||||
else if (music_obj.enableCategories.length == 0) setDefaults = true;
|
||||
else if (music_obj.enableCategories.length === 0) setDefaults = true;
|
||||
if (!music_obj.enableSongs) setDefaults = true;
|
||||
else if (music_obj.enableSongs.length == 0) setDefaults = true;
|
||||
else if (music_obj.enableSongs.length === 0) setDefaults = true;
|
||||
|
||||
if (setDefaults === true) {
|
||||
// set up defaults
|
||||
@@ -1355,10 +1355,10 @@ class WTVBGMusic {
|
||||
musiclist[k].id = k;
|
||||
if (String(category).length === 1) {
|
||||
// 3 digit song id
|
||||
if (parseInt(k.slice(0, 1)) == parseInt(category) && String(k).length === 3) songList.push(musiclist[k]);
|
||||
if (parseInt(k.slice(0, 1)) === parseInt(category) && String(k).length === 3) songList.push(musiclist[k]);
|
||||
} else if (String(category).length === 2) {
|
||||
// 4 digit song id
|
||||
if (parseInt(k.slice(0, 2)) == parseInt(category) && String(k).length === 4) songList.push(musiclist[k]);
|
||||
if (parseInt(k.slice(0, 2)) === parseInt(category) && String(k).length === 4) songList.push(musiclist[k]);
|
||||
}
|
||||
});
|
||||
return songList.filter(value => Object.keys(value).length !== 0);
|
||||
@@ -1385,7 +1385,7 @@ class WTVBGMusic {
|
||||
const music_obj = this.getMusicObj();
|
||||
let enabled = false;
|
||||
music_obj.enableCategories.forEach(function (v) {
|
||||
if (parseInt(v) == parseInt(category)) {
|
||||
if (parseInt(v) === parseInt(category)) {
|
||||
enabled = true;
|
||||
}
|
||||
});
|
||||
@@ -1396,7 +1396,7 @@ class WTVBGMusic {
|
||||
const music_obj = this.getMusicObj();
|
||||
let enabled = false;
|
||||
music_obj.enableSongs.forEach(function (v) {
|
||||
if (parseInt(v) == parseInt(song)) {
|
||||
if (parseInt(v) === parseInt(song)) {
|
||||
if (checkCat) {
|
||||
const songCategory = this.getSongCategory(song);
|
||||
if (this.isCategoryEnabled(songCategory)) {
|
||||
|
||||
@@ -89,7 +89,7 @@ class WTVClientCapabilities {
|
||||
const capabilities = [];
|
||||
|
||||
// might want to pass without a flag to get the table
|
||||
if (wtv_capability_flags != null) {
|
||||
if (wtv_capability_flags !== null) {
|
||||
|
||||
// define function to convert hex string to binary string (0s & 1s)
|
||||
const hex2bin = function (hex) {
|
||||
@@ -118,7 +118,7 @@ class WTVClientCapabilities {
|
||||
// process bitfield and set capabilities
|
||||
Object.keys(bitfield).forEach(function (k) {
|
||||
// Convert binary to boolean, 0 to false, 1 to true
|
||||
const bitfield_result = (bitfield[k] == "1")
|
||||
const bitfield_result = (bitfield[k] === "1")
|
||||
|
||||
// set flags based on position of bit
|
||||
try {
|
||||
|
||||
@@ -148,7 +148,7 @@ class WTVClientSessionData {
|
||||
if (addresses) {
|
||||
for (let i = 0; i < addresses.length; i++) {
|
||||
console.log(addr.toLowerCase(), addresses[i].address.toLowerCase())
|
||||
if (addr.toLowerCase() == addresses[i].address.toLowerCase()) {
|
||||
if (addr.toLowerCase() === addresses[i].address.toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ class WTVClientSessionData {
|
||||
}
|
||||
|
||||
findFreeUserSlot() {
|
||||
if (this.user_id != 0) return false; // subscriber only command
|
||||
if (this.user_id !== 0) return false; // subscriber only command
|
||||
const master_directory = this.getUserStoreDirectory(true);
|
||||
if (this.fs.existsSync(master_directory)) {
|
||||
for (let i = 0; i < this.minisrv_config.config.user_accounts.max_users_per_account; i++) {
|
||||
@@ -171,17 +171,17 @@ class WTVClientSessionData {
|
||||
}
|
||||
|
||||
getDisplayName() {
|
||||
return (this.user_id == 0) ? this.getSessionData("subscriber_name") : this.getSessionData("display_name");
|
||||
return (this.user_id === 0) ? this.getSessionData("subscriber_name") : this.getSessionData("display_name");
|
||||
}
|
||||
|
||||
getNumberOfUserAccounts() {
|
||||
if (!this.isRegistered()) return false;
|
||||
if (this.user_id != 0) return false; // subscriber only command
|
||||
if (this.user_id !== 0) return false; // subscriber only command
|
||||
return Object.keys(this.listPrimaryAccountUsers()).length;
|
||||
}
|
||||
|
||||
listPrimaryAccountUsers() {
|
||||
if (this.user_id != 0) return false; // subscriber only command
|
||||
if (this.user_id !== 0) return false; // subscriber only command
|
||||
|
||||
const master_directory = this.getUserStoreDirectory(true);
|
||||
const account_data = [];
|
||||
@@ -191,7 +191,7 @@ class WTVClientSessionData {
|
||||
if (f.startsWith("user")) {
|
||||
const user_file = this.path.resolve(master_directory + this.path.sep + f + this.path.sep + f + ".json");
|
||||
if (self.fs.existsSync(user_file)) {
|
||||
if (f == "user0") {
|
||||
if (f === "user0") {
|
||||
account_data['subscriber'] = JSON.parse(this.fs.readFileSync(user_file));
|
||||
account_data['subscriber'].user_id = 0;
|
||||
}
|
||||
@@ -283,14 +283,14 @@ class WTVClientSessionData {
|
||||
const pending_file = this.getUserStoreDirectory(true) + this.path.sep + "pending_transfer.json";
|
||||
const file = this.fs.readFileSync(pending_file)
|
||||
const ssidobj = JSON.parse(file);
|
||||
if (ssidobj.type != "target") return false; // Only allow completion from target
|
||||
if (ssidobj.type !== "target") return false; // Only allow completion from target
|
||||
const source_ssid = ssidobj.ssid
|
||||
const old_account = this.getAccountStoreDirectory() + this.path.sep + source_ssid
|
||||
const new_account = this.getUserStoreDirectory(true);
|
||||
this.fs.cpSync(old_account, new_account, {
|
||||
filter: (source, _destination) => {
|
||||
return source != "pending_transfer.json";
|
||||
},
|
||||
return source !== "pending_transfer.json";
|
||||
},
|
||||
recursive: true
|
||||
});
|
||||
this.fs.rmSync(old_account, { recursive: true })
|
||||
@@ -304,7 +304,7 @@ class WTVClientSessionData {
|
||||
const ssidobj = JSON.parse(this.fs.readFileSync(pending_file));
|
||||
console.log(ssidobj)
|
||||
if (dtype) {
|
||||
(ssidobj.type == dtype) ? ssidobj.ssid : false;
|
||||
(ssidobj.type === dtype) ? ssidobj.ssid : false;
|
||||
}
|
||||
else {
|
||||
return ssidobj;
|
||||
@@ -543,7 +543,7 @@ class WTVClientSessionData {
|
||||
let cookie_data;
|
||||
if (!this.checkCookies()) this.resetCookies();
|
||||
if (!domain) return false;
|
||||
else if (typeof (domain) == 'object') {
|
||||
else if (typeof (domain) === 'object') {
|
||||
// accept array as first argument
|
||||
if (domain.domain && domain.path && domain.expires && domain.data) cookie_data = domain;
|
||||
else return false;
|
||||
@@ -564,7 +564,7 @@ class WTVClientSessionData {
|
||||
// see if we have a cookie for this domain/path
|
||||
Object.keys(this.session_store.cookies).forEach(function (k) {
|
||||
if (cookie_index >= 0) return;
|
||||
if (domain == self.session_store.cookies[k].domain && path == self.session_store.cookies[k].path) cookie_index = k;
|
||||
if (domain === self.session_store.cookies[k].domain && path === self.session_store.cookies[k].path) cookie_index = k;
|
||||
});
|
||||
// otherwise add a new one
|
||||
if (cookie_index === -1) cookie_index = this.countCookies();
|
||||
@@ -586,8 +586,8 @@ class WTVClientSessionData {
|
||||
let result = false;
|
||||
Object.keys(this.session_store['cookies']).forEach(function (k) {
|
||||
if (result !== false) return;
|
||||
if (self.session_store['cookies'][k].domain == domain &&
|
||||
self.session_store['cookies'][k].path == path) {
|
||||
if (self.session_store['cookies'][k].domain === domain &&
|
||||
self.session_store['cookies'][k].path === path) {
|
||||
|
||||
const current_epoch_utc = Date.parse((new Date()).toUTCString());
|
||||
const cookie_expires_epoch_utc = Date.parse(new Date(Date.parse(self.session_store['cookies'][k].expires)).toUTCString());
|
||||
@@ -621,7 +621,7 @@ class WTVClientSessionData {
|
||||
return true;
|
||||
}
|
||||
if (!domain) return false;
|
||||
else if (typeof (domain) == 'object') {
|
||||
else if (typeof (domain) === 'object') {
|
||||
// accept array as first argument
|
||||
if (domain.domain && domain.path) {
|
||||
path = domain.path;
|
||||
@@ -633,7 +633,7 @@ class WTVClientSessionData {
|
||||
|
||||
const self = this;
|
||||
Object.keys(this.session_store['cookies']).forEach(function (k) {
|
||||
if (self.session_store['cookies'][k].domain == domain && self.session_store['cookies'][k].path == path) {
|
||||
if (self.session_store['cookies'][k].domain === domain && self.session_store['cookies'][k].path === path) {
|
||||
delete self.session_store['cookies'][k];
|
||||
self.storeSessionData();
|
||||
result = true;
|
||||
@@ -649,7 +649,7 @@ class WTVClientSessionData {
|
||||
*/
|
||||
checkCookies() {
|
||||
if (!this.session_store.cookies) return false;
|
||||
else if (this.session_store.cookies == []) return false;
|
||||
else if (this.session_store.cookies.length === 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -677,7 +677,7 @@ class WTVClientSessionData {
|
||||
}
|
||||
} catch (e) {
|
||||
// Don't log error 'file not found', it just means the client isn't registered yet
|
||||
if (e.code != "ENOENT") console.error(" # Error loading session data for", this.wtvshared.filterSSID(this.ssid), e);
|
||||
if (e.code !== "ENOENT") console.error(" # Error loading session data for", this.wtvshared.filterSSID(this.ssid), e);
|
||||
// also wipe any existing session_store
|
||||
this.session_store = {};
|
||||
return false;
|
||||
@@ -723,7 +723,7 @@ class WTVClientSessionData {
|
||||
|
||||
validateUserPassword(passwd) {
|
||||
if (!this.getUserPasswordEnabled()) return true; // no password is set so always validate
|
||||
return (this.encodePassword(passwd) == this.getSessionData("subscriber_password"));
|
||||
return (this.encodePassword(passwd) === this.getSessionData("subscriber_password"));
|
||||
}
|
||||
|
||||
isUserLoggedIn() {
|
||||
@@ -761,7 +761,7 @@ class WTVClientSessionData {
|
||||
if (!this.fs.existsSync(storeDir)) this.mkdirRecursive(storeDir);
|
||||
|
||||
if (sessionToStore.password_valid) delete sessionToStore.password_valid; // do not save validity state of password login, resets when session expires
|
||||
if (json_save_data != json_load_data) this.fs.writeFileSync(storeDir + "user" + this.user_id + ".json", JSON.stringify(sessionToStore), "Utf8");
|
||||
if (json_save_data !== json_load_data) this.fs.writeFileSync(storeDir + "user" + this.user_id + ".json", JSON.stringify(sessionToStore), "Utf8");
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error(" # Error saving session data for", this.wtvshared.filterSSID(this.ssid), e);
|
||||
@@ -904,11 +904,9 @@ class WTVClientSessionData {
|
||||
switch (this.get("wtv-client-rom-type")) {
|
||||
case "US-DTV-disk-0MB-16MB-softmodem-CPU5230":
|
||||
case "US-DTV-disk-0MB-32MB-softmodem-CPU5230":
|
||||
return "UltimateTV Satellite receiver";
|
||||
|
||||
case "US-WEBSTAR-disk-0MB-8MB-softmodem-CPU5230":
|
||||
case "US-WEBSTAR-disk-0MB-16MB-softmodem-CPU5230":
|
||||
return "WebTV Satellite receiver";
|
||||
return "satellite receiver";
|
||||
|
||||
case "US-LC2-flashdisk-0MB-16MB-softmodem-CPU5230":
|
||||
case "US-LC2-disk-0MB-8MB":
|
||||
@@ -922,10 +920,10 @@ class WTVClientSessionData {
|
||||
case "JP-LC2-disk-0MB-8MB-CPU5230":
|
||||
case "JP-LC2-disk-0MB-16MB-CPU5230":
|
||||
case "JP-LC2-flash-2MB-8MB-CPU5230":
|
||||
return "WebTV Plus receiver";
|
||||
return "Plus receiver";
|
||||
|
||||
default:
|
||||
return "WebTV Internet receiver";
|
||||
return "Internet terminal";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -954,7 +952,7 @@ class WTVClientSessionData {
|
||||
ssid_access_list_ip_override = true;
|
||||
}
|
||||
} else {
|
||||
if (self.clientAddress == self.minisrv_config.config.ssid_ip_allow_list[self.ssid][k]) {
|
||||
if (self.clientAddress === self.minisrv_config.config.ssid_ip_allow_list[self.ssid][k]) {
|
||||
// remoteAddr directly matches IP
|
||||
ssid_access_list_ip_override = true;
|
||||
}
|
||||
@@ -972,7 +970,7 @@ class WTVClientSessionData {
|
||||
|
||||
// process whitelist first
|
||||
if (self.ssid && self.minisrv_config.config.ssid_allow_list) {
|
||||
const ssid_is_in_whitelist = self.minisrv_config.config.ssid_allow_list.findIndex(element => element == self.ssid);
|
||||
const ssid_is_in_whitelist = self.minisrv_config.config.ssid_allow_list.findIndex(element => element === self.ssid);
|
||||
if (ssid_is_in_whitelist === -1) {
|
||||
// no whitelist match, but lets see if the remoteAddress is allowed
|
||||
checkSSIDIPWhitelist(self.ssid, false);
|
||||
@@ -981,7 +979,7 @@ class WTVClientSessionData {
|
||||
|
||||
// now check blacklist
|
||||
if (self.ssid && self.minisrv_config.config.ssid_block_list) {
|
||||
const ssid_is_in_blacklist = self.minisrv_config.config.ssid_block_list.findIndex(element => element == self.ssid);
|
||||
const ssid_is_in_blacklist = self.minisrv_config.config.ssid_block_list.findIndex(element => element === self.ssid);
|
||||
if (ssid_is_in_blacklist !== -1) {
|
||||
// blacklist match, but lets see if the remoteAddress is allowed
|
||||
checkSSIDIPWhitelist(self.ssid, true);
|
||||
@@ -1000,7 +998,7 @@ class WTVClientSessionData {
|
||||
|
||||
isAuthorized(url, whitelist = 'lockdown', ignore_lockdown = false) {
|
||||
// not in lockdown so just return true
|
||||
if (whitelist == 'lockdown' && !this.lockdown && !ignore_lockdown) return true;
|
||||
if (whitelist === 'lockdown' && !this.lockdown && !ignore_lockdown) return true;
|
||||
|
||||
// in lockdown, check whitelisted urls
|
||||
const self = this;
|
||||
@@ -1057,25 +1055,25 @@ class WTVClientSessionData {
|
||||
const romtype = this.get("wtv-client-rom-type");
|
||||
const brandId = this.ssid.charAt(8)
|
||||
|
||||
if (brandId == 0)
|
||||
if (url && romtype == "US-DTV-disk-0MB-32MB-softmodem-CPU5230")
|
||||
if (brandId === 0)
|
||||
if (url && romtype === "US-DTV-disk-0MB-32MB-softmodem-CPU5230")
|
||||
return "Sony/DirecTV";
|
||||
else
|
||||
return "Sony";
|
||||
else if (brandId == 1)
|
||||
else if (brandId === 1)
|
||||
if (url && isPlus === true)
|
||||
return "Philips-Plus";
|
||||
else
|
||||
return "Philips";
|
||||
else if (brandId == 4)
|
||||
else if (brandId === 4)
|
||||
return "Mitsubishi";
|
||||
else if (brandId == 5)
|
||||
else if (brandId === 5)
|
||||
return "Philips-Mont";
|
||||
else if (brandId == 7)
|
||||
else if (brandId === 7)
|
||||
return "Samsung";
|
||||
else if (brandId == 9)
|
||||
else if (brandId === 9)
|
||||
if (url)
|
||||
if (romtype == "US-DTV-disk-0MB-32MB-softmodem-CPU5230")
|
||||
if (romtype === "US-DTV-disk-0MB-32MB-softmodem-CPU5230")
|
||||
return "Thomson/DirecTV";
|
||||
else
|
||||
return "Thomson";
|
||||
|
||||
@@ -159,9 +159,9 @@ class WTVDownloadList {
|
||||
this.download_list += `group: ${group}-UPDATE\n`;
|
||||
this.download_list += `location: ${source}\n`;
|
||||
this.download_list += `file-permission: ${file_permission}\n`;
|
||||
if (checksum != null) this.download_list += `wtv-checksum: ${checksum}\n`;
|
||||
if (uncompressed_size != null) this.download_list += `wtv-uncompressed-filesize: ${uncompressed_size}\n`;
|
||||
this.download_list += `service-source-location: /webtv/content/${source.slice(source.indexOf('-') + 1, source.indexOf(':/'))}d/${source.slice(source.indexOf(':/') + 2)}\n`;
|
||||
if (checksum !== null) this.download_list += `wtv-checksum: ${checksum}\n`;
|
||||
if (uncompressed_size !== null) this.download_list += `wtv-uncompressed-filesize: ${uncompressed_size}\n`;
|
||||
this.download_list += `service-source-location: /webtv/content/${source.slice(source.indexOf('-') + 1, source.indexOf(':/'))}d/${source.slice(source.indexOf(':/') + 2)}\n`;
|
||||
this.download_list += `client-dest-location: ${path}\n\n`;
|
||||
}
|
||||
|
||||
@@ -180,10 +180,10 @@ class WTVDownloadList {
|
||||
}
|
||||
|
||||
getGroupDataFromClientPost(post_data) {
|
||||
if (typeof post_data == 'string') post_data = post_data.split("\n\n");
|
||||
if (typeof post_data === 'string') post_data = post_data.split("\n\n");
|
||||
const group_data = [];
|
||||
post_data.forEach(function (v) {
|
||||
if (v.slice(0, 4) == "file") {
|
||||
if (v.slice(0, 4) === "file") {
|
||||
const block_split = v.split("\n");
|
||||
const group_data_entry = {};
|
||||
group_data_entry.path = block_split[0];
|
||||
|
||||
@@ -87,7 +87,7 @@ class WTVFavorites {
|
||||
const self = this;
|
||||
if (folder_templates[folder]) {
|
||||
Object.keys(folder_templates[folder]).forEach(function (k) {
|
||||
self.createFavorite(folder_templates[folder][k].title, folder_templates[folder][k].url, folder, (folder_templates[folder][k].image_type == "image/wtv-bitmap") ? atob(folder_templates[folder][k].image) : folder_templates[folder][k].image, folder_templates[folder][k].image_type);
|
||||
self.createFavorite(folder_templates[folder][k].title, folder_templates[folder][k].url, folder, (folder_templates[folder][k].image_type === "image/wtv-bitmap") ? atob(folder_templates[folder][k].image) : folder_templates[folder][k].image, folder_templates[folder][k].image_type);
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -95,12 +95,12 @@ class WTVFavorites {
|
||||
createDefaultFolders() {
|
||||
const brandId = this.ssid.charAt(8);
|
||||
this.createTemplateFolder("Recommended");
|
||||
if (brandId == 7)
|
||||
if (brandId === 7)
|
||||
this.createTemplateFolder("Personal (Samsung)");
|
||||
else
|
||||
this.createTemplateFolder("Personal");
|
||||
|
||||
if (brandId == 0)
|
||||
|
||||
if (brandId === 0)
|
||||
this.createTemplateFolder("Sony");
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ class WTVFavorites {
|
||||
const favoriteid = this.createFavoriteID();
|
||||
const favoritefile = favoriteid + this.favFileExt;
|
||||
const favoritefileout = folderpath + favoritefile;
|
||||
if (imagetype != "url")
|
||||
if (imagetype !== "url")
|
||||
image = btoa(image);
|
||||
|
||||
title = decodeURIComponent(title).replaceAll("+", " ");
|
||||
@@ -307,7 +307,7 @@ class WTVFavorites {
|
||||
const keydata = JSON.parse(this.fs.readFileSync(favoritefileout));
|
||||
const keys = Object.keys(keydata);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
if (keydata[keys[i]].id == favoriteid) {
|
||||
if (keydata[keys[i]].id === favoriteid) {
|
||||
return { key: keys[i], folder: keydata[keys[i]].folder };
|
||||
}
|
||||
}
|
||||
@@ -419,7 +419,7 @@ class WTVFavorites {
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (oldkey != "none") {
|
||||
if (oldkey !== "none") {
|
||||
keydata[oldkey].folder = null;
|
||||
keydata[oldkey].id = null;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class WTVFlashrom {
|
||||
|
||||
flashrom_info.magic = part_header.toString('hex', 0, 4);
|
||||
flashrom_info.valid_flashrom = false;
|
||||
if (flashrom_info.magic == flashrom_magic) flashrom_info.valid_flashrom = true;
|
||||
if (flashrom_info.magic === flashrom_magic) flashrom_info.valid_flashrom = true;
|
||||
if (!flashrom_info.valid_flashrom) console.error(" * Warning! FlashROM File Magic (" + flashrom_info.magic + ") did not match expected magic (" + flashrom_magic + ")...");
|
||||
|
||||
//if (this.minisrv_config.config.debug_flags.debug && !this.no_debug) console.log(" # FlashROM File Magic (" + flashrom_info.magic + "), expected magic (" + flashrom_magic + "), OK = " + flashrom_info.valid_flashrom + "...");
|
||||
@@ -88,7 +88,7 @@ class WTVFlashrom {
|
||||
flashrom_info.part_number = data.readUInt16BE(28);
|
||||
|
||||
if (this.minisrv_config.config.debug_flags.debug && !this.minisrv_config.config.debug_flags.quiet && !this.no_debug) console.log(" # Flashrom Curr Part Number :", flashrom_info.part_number);
|
||||
flashrom_info.is_last_part = ((flashrom_info.byte_progress + flashrom_info.part_total_size) == flashrom_info.total_parts_size) ? true : false;
|
||||
flashrom_info.is_last_part = ((flashrom_info.byte_progress + flashrom_info.part_total_size) === flashrom_info.total_parts_size) ? true : false;
|
||||
|
||||
if (flashrom_info.is_last_part) {
|
||||
if (this.minisrv_config.config.debug_flags.debug && !this.minisrv_config.config.debug_flags.quiet && !this.no_debug) console.log(" # Flashrom Curr Part is Last:", flashrom_info.is_last_part);
|
||||
@@ -117,7 +117,7 @@ class WTVFlashrom {
|
||||
const flashrom_info = this.getFlashromInfo(data, request_path)
|
||||
if (flashrom_info.is_bootrom) headers += "Content-Type: binary/x-wtv-bootrom"; // maybe?
|
||||
else headers += "Content-Type: binary/x-wtv-flashblock";
|
||||
if (flashrom_info.next_rompath != null && this.bf0app_update) headers += "\nwtv-visit: " + flashrom_info.next_rompath;
|
||||
if (flashrom_info.next_rompath !== null && this.bf0app_update) headers += "\nwtv-visit: " + flashrom_info.next_rompath;
|
||||
headers += "\nminisrv-no-mail-count: true";
|
||||
callback(data, headers);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ class WTVFlashrom {
|
||||
let headers, data, flashrom_file_path = null;
|
||||
const self = this;
|
||||
Object.keys(self.service_vaults).forEach(function (g) {
|
||||
if (flashrom_file_path != null) return;
|
||||
if (flashrom_file_path !== null) return;
|
||||
flashrom_file_path = self.service_vaults[g] + "/" + self.service_name + "/" + request_path;
|
||||
if (!self.fs.existsSync(flashrom_file_path)) flashrom_file_path = null;
|
||||
});
|
||||
@@ -160,11 +160,11 @@ class WTVFlashrom {
|
||||
|
||||
res.on('end', function () {
|
||||
if (self.minisrv_config.config.debug_flags.debug) console.log(` * minisrv FlashROM Server HTTP Status: ${res.statusCode} ${res.statusMessage}`)
|
||||
if (res.statusCode == 200) {
|
||||
if (res.statusCode === 200) {
|
||||
data = Buffer.from(data_hex, 'hex');
|
||||
} else if (res.statusCode == 206) {
|
||||
} else if (res.statusCode === 206) {
|
||||
data = self.getFlashromInfo(Buffer.from(data_hex, 'hex'), request_path);
|
||||
} else if (res.statusCode == 404) {
|
||||
} else if (res.statusCode === 404) {
|
||||
const errpage = self.wtvshared.doErrorPage(404, "The service could not find the requested ROM on the minisrv FlashROM server.")
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
@@ -173,7 +173,7 @@ class WTVFlashrom {
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
}
|
||||
if (!headers && res.statusCode != 206) {
|
||||
if (!headers && res.statusCode !== 206) {
|
||||
self.sendToClient(data, request_path, callback);
|
||||
} else {
|
||||
callback(data, headers);
|
||||
@@ -182,7 +182,7 @@ class WTVFlashrom {
|
||||
});
|
||||
req.end();
|
||||
} else {
|
||||
this.doLocalFlashROM(flashrom_file_path, request_path, callback, ((length != 0) ? true : false));
|
||||
this.doLocalFlashROM(flashrom_file_path, request_path, callback, ((length !== 0) ? true : false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class WTVGuide {
|
||||
start = start + search.length;
|
||||
const original_start = start;
|
||||
// handle <word="whatever">
|
||||
if (definition.charAt(start) != ">") {
|
||||
if (definition.charAt(start) !== ">") {
|
||||
start++; // +1 to skip =
|
||||
end = definition.indexOf(">", start);
|
||||
if (end === -1) break; // malformed tag, exit loop
|
||||
@@ -99,10 +99,7 @@ class WTVGuide {
|
||||
// replaces <boxname> with the friendly name of the type of unit the user has
|
||||
while (definition.indexOf("<boxname>") >= 0) {
|
||||
const romtype = this.session_data.get("wtv-client-rom-type");
|
||||
let boxname = "";
|
||||
if (romtype == "US-WEBSTAR-disk-0MB-16MB-softmodem-CPU5230" || romtype == "US-DTV-disk-0MB-32MB-softmodem-CPU5230") boxname = "satellite receiver"
|
||||
else if (this.session_data.capabilities.get("client-has-tv-experience")) boxname = "WebTV Plus receiver";
|
||||
else boxname = "WebTV Internet terminal";
|
||||
const boxname = this.wtvshared.getBoxName(romtype);
|
||||
definition = definition.replace(/\<boxname\>/g, boxname);
|
||||
}
|
||||
// replaces <boxname_plus> with either "WebTV" or "WebTV Plus" depending on user box type
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -119,7 +119,7 @@ class WTVMail {
|
||||
getMailboxByName(mailbox_name) {
|
||||
let mailbox_id = false;
|
||||
this.mailboxes.every(function (v, k) {
|
||||
if (v.toLowerCase() == mailbox_name.toLowerCase()) {
|
||||
if (v.toLowerCase() === mailbox_name.toLowerCase()) {
|
||||
mailbox_id = k;
|
||||
return false;
|
||||
}
|
||||
@@ -238,7 +238,7 @@ class WTVMail {
|
||||
subj = header[1];
|
||||
break;
|
||||
}
|
||||
} else if (line == '') end_of_headers = true;
|
||||
} else if (line === '') end_of_headers = true;
|
||||
else {
|
||||
msg += line.replace(/\$\{(\w{1,})\}/g, function (x) {
|
||||
let out = '';
|
||||
@@ -327,7 +327,7 @@ class WTVMail {
|
||||
if (v.name.slice((v.name.length - self.msgFileExt.length)) === self.msgFileExt) return v.name.slice(0, (v.name.length - 5));
|
||||
});
|
||||
|
||||
if (files.length == 0) return false; // no messages
|
||||
if (files.length === 0) return false; // no messages
|
||||
else {
|
||||
// todo filter previous results when offset
|
||||
const messagelist_out = new Array();
|
||||
@@ -388,7 +388,7 @@ class WTVMail {
|
||||
const temp_session_data_file = self.fs.readFileSync(search_dir + self.path.sep + file, 'Utf8');
|
||||
const temp_session_data = JSON.parse(temp_session_data_file);
|
||||
if (temp_session_data.subscriber_username) {
|
||||
if (temp_session_data.subscriber_username.toLowerCase() == username.toLowerCase()) {
|
||||
if (temp_session_data.subscriber_username.toLowerCase() === username.toLowerCase()) {
|
||||
// Use the absolute path for replacement since search_dir is now absolute
|
||||
const accounts_dir = self.wtvshared.getAbsolutePath(self.minisrv_config.config.SessionStore + self.path.sep + "accounts" + self.path.sep);
|
||||
let path_after_replace = search_dir.replace(accounts_dir, '');
|
||||
@@ -505,7 +505,7 @@ class WTVMail {
|
||||
const mailbox_name = this.getMessageMailboxName(messageid);
|
||||
if (!mailbox_name) return false;
|
||||
|
||||
const mailboxid = this.mailboxes.findIndex((value) => value == mailbox_name);
|
||||
const mailboxid = this.mailboxes.findIndex((value) => value === mailbox_name);
|
||||
|
||||
if (mailboxid !== false) return this.getMessage(mailboxid, messageid);
|
||||
return null;
|
||||
@@ -515,7 +515,7 @@ class WTVMail {
|
||||
// returns true if successful, false if failed.
|
||||
const currentMailbox = this.getMessageMailboxID(messageid);
|
||||
// Same mailbox
|
||||
if (dest_mailbox_id == currentMailbox) return false;
|
||||
if (dest_mailbox_id === currentMailbox) return false;
|
||||
|
||||
// Invalid destination mailbox ID
|
||||
if (dest_mailbox_id > (this.mailboxes.length - 1) || dest_mailbox_id < 0) return false;
|
||||
@@ -540,7 +540,7 @@ class WTVMail {
|
||||
deleteMessage(messageid) {
|
||||
const currentMailbox = this.getMessageMailboxName(messageid);
|
||||
const trashMailbox = this.getMailboxByName(this.trashMailboxName);
|
||||
if (currentMailbox != trashMailbox) {
|
||||
if (currentMailbox !== trashMailbox) {
|
||||
// if not in the trash, move it to trash
|
||||
return this.moveMailMessage(messageid, trashMailbox);
|
||||
} else {
|
||||
|
||||
@@ -35,7 +35,7 @@ class WTVMime {
|
||||
if (ssid_session) {
|
||||
// if gzip is enabled...
|
||||
if (this.minisrv_config.config.enable_gzip_compression || this.minisrv_config.config.force_compression_type) {
|
||||
const is_bf0app = ssid_session.get("wtv-client-rom-type") == "bf0app";
|
||||
const is_bf0app = ssid_session.get("wtv-client-rom-type") === "bf0app";
|
||||
const isOldBuild = this.wtvshared.isOldBuild(ssid_session);
|
||||
let is_softmodem = false;
|
||||
if (ssid_session.get("wtv-client-rom-type")) is_softmodem = ssid_session.get("wtv-client-rom-type").match(/softmodem/);
|
||||
@@ -52,23 +52,23 @@ class WTVMime {
|
||||
|
||||
|
||||
// mostly for debugging
|
||||
if (this.minisrv_config.config.force_compression_type == "lzpf") compression_type = 1;
|
||||
if (this.minisrv_config.config.force_compression_type == "gzip") compression_type = 2;
|
||||
if (this.minisrv_config.config.force_compression_type === "lzpf") compression_type = 1;
|
||||
if (this.minisrv_config.config.force_compression_type === "gzip") compression_type = 2;
|
||||
|
||||
// do not compress if already encoded
|
||||
if (headers_obj["Content-Encoding"]) return 0;
|
||||
|
||||
// should we bother to compress?
|
||||
let content_type = "";
|
||||
if (typeof (headers_obj) == 'string') content_type = headers_obj;
|
||||
if (typeof (headers_obj) === 'string') content_type = headers_obj;
|
||||
else content_type = (typeof (headers_obj["wtv-modern-content-type"]) !== 'undefined') ? headers_obj["wtv-modern-content-type"] : headers_obj["Content-type"];
|
||||
|
||||
if (content_type) {
|
||||
// both lzpf and gzip
|
||||
if (content_type.match(/^text\//) && content_type != "text/tellyscript") compress_data = true;
|
||||
if (content_type.match(/^text\//) && content_type !== "text/tellyscript") compress_data = true;
|
||||
else if (content_type.match(/^application\/(x-?)javascript$/)) compress_data = true;
|
||||
else if (content_type == "application/json") compress_data = true;
|
||||
if (compression_type == 2) {
|
||||
else if (content_type === "application/json") compress_data = true;
|
||||
if (compression_type === 2) {
|
||||
// gzip only
|
||||
if (content_type.match(/^audio\/(x-)?(s3m|mod|xm|midi|wav|wave|aif(f)?)$/)) compress_data = true; // s3m, mod, xm, midi & wav
|
||||
if (content_type.match(/^application\/karaoke$/)) compress_data = true; // midi karaoke
|
||||
|
||||
@@ -37,13 +37,13 @@ class WTVNews {
|
||||
connectUsenet() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.client.connect().then((response) => {
|
||||
if (response.code == 200 || response.code == 201) {
|
||||
if (response.code == 201) this.posting_allowed = false;
|
||||
if (response.code === 200 || response.code === 201) {
|
||||
if (response.code === 201) this.posting_allowed = false;
|
||||
if (this.username && this.password) {
|
||||
this.client.authInfoUser(this.username).then((res) => {
|
||||
if (res.code == "381") {
|
||||
if (res.code === 381) {
|
||||
res.authInfoPass(this.password).then((res) => {
|
||||
if (res.code == 281) resolve(true);
|
||||
if (res.code === 281) resolve(true);
|
||||
else reject(res.description);
|
||||
}).catch((e) => {
|
||||
console.error(" * WTVNews Error:", "Command: connect", e);
|
||||
@@ -124,7 +124,7 @@ class WTVNews {
|
||||
selectGroup(group) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.client.group(group).then((response) => {
|
||||
if (response.code == 211) resolve(response);
|
||||
if (response.code === 211) resolve(response);
|
||||
else reject(`No such group <b>${group}</b>`);
|
||||
}).catch((e) => {
|
||||
console.error(" * WTVNews Error:", "Command: selectGroup", e);
|
||||
@@ -241,7 +241,7 @@ class WTVNews {
|
||||
let response;
|
||||
if (message.article.headers) {
|
||||
Object.keys(message.article.headers).forEach((k) => {
|
||||
if (k.toLowerCase() == header.toLowerCase()) {
|
||||
if (k.toLowerCase() === header.toLowerCase()) {
|
||||
response = message.article.headers[k];
|
||||
return false;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ class WTVNews {
|
||||
quitUsenet() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.client.quit().then((response) => {
|
||||
if (response.code == 205) resolve(true);
|
||||
if (response.code === 205) resolve(true);
|
||||
else {
|
||||
console.error(" * WTVNews Error:", "Command: quit", response.code);
|
||||
reject(`Unexpected response code ${response.code}`);
|
||||
@@ -290,7 +290,7 @@ class WTVNews {
|
||||
Promise.all(promises).then(() => {
|
||||
this.client.post()
|
||||
.then((response) => {
|
||||
if (response.code == 340) {
|
||||
if (response.code === 340) {
|
||||
const articleData = {};
|
||||
articleData.headers = {
|
||||
'Relay-Version': "version zefie_wtvp_minisrv " + this.minisrv_config.version + "; site " + this.minisrv_config.config.domain_name,
|
||||
@@ -356,7 +356,7 @@ class WTVNews {
|
||||
const messages = [];
|
||||
const promises = [];
|
||||
for (const article in NGArticles) {
|
||||
if (article == "getCaseInsensitiveKey" || isNaN(article)) continue;
|
||||
if (article === "getCaseInsensitiveKey" || isNaN(article)) continue;
|
||||
promises.push(new Promise((resolve, reject) => {
|
||||
this.getHeader(NGArticles[article]).then((data) => {
|
||||
if (data.article) messages.push(data.article)
|
||||
@@ -419,7 +419,7 @@ class WTVNews {
|
||||
section_match = line.match(/^Content-Transfer-Encoding: (.+)/i)
|
||||
if (section_match) attachments[i].content_encoding = section_match[1];
|
||||
} else {
|
||||
if (section_type != null) {
|
||||
if (section_type !== null) {
|
||||
if (section_type.match("text/plain")) message_body += line;
|
||||
else {
|
||||
if (attachments[i].data) attachments[i].data += line;
|
||||
@@ -459,7 +459,7 @@ class WTVNews {
|
||||
const messageId = messages[k].messageId;
|
||||
const ref = messages[k].headers.REFERENCES;
|
||||
if (ref) {
|
||||
const res = message_id_roots.find(e => e.messageId == ref);
|
||||
const res = message_id_roots.find(e => e.messageId === ref);
|
||||
if (res) {
|
||||
// see if its attached to a root post
|
||||
if (message_relations[res.messageId]) message_relations[res.messageId].push({ "messageId": messageId, "index": k });
|
||||
@@ -473,11 +473,11 @@ class WTVNews {
|
||||
if (message_relations[j].length > 0) {
|
||||
Object.keys(message_relations[j]).forEach((h) => {
|
||||
if (found) return;
|
||||
if (message_relations[j][h].messageId == ref) {
|
||||
if (message_relations[j][h].messageId === ref) {
|
||||
let searchref = messages[message_relations[j][h].index].headers.REFERENCES || null;
|
||||
let mainref = j; // j is already the main reference messageId
|
||||
while (searchref !== null) {
|
||||
const searchart = messages.find(e => e.messageId == searchref);
|
||||
const searchart = messages.find(e => e.messageId === searchref);
|
||||
if (searchart) {
|
||||
mainref = searchart.messageId;
|
||||
searchref = searchart.headers.REFERENCES || null;
|
||||
@@ -495,7 +495,7 @@ class WTVNews {
|
||||
|
||||
// If not found in relations, add as root (but check for duplicates first)
|
||||
if (!found) {
|
||||
const existingRoot = message_id_roots.find(e => e.messageId == messageId);
|
||||
const existingRoot = message_id_roots.find(e => e.messageId === messageId);
|
||||
if (!existingRoot) {
|
||||
message_id_roots.push({ "messageId": messageId, "index": k });
|
||||
}
|
||||
@@ -504,7 +504,7 @@ class WTVNews {
|
||||
}
|
||||
else {
|
||||
// Check for duplicates before adding as root
|
||||
const existingRoot = message_id_roots.find(e => e.messageId == messageId);
|
||||
const existingRoot = message_id_roots.find(e => e.messageId === messageId);
|
||||
if (!existingRoot) {
|
||||
message_id_roots.push({ "messageId": messageId, "index": k });
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class WTVNewsServer {
|
||||
...nntp_server.prototype,
|
||||
_authenticate: function (session) {
|
||||
// authenticate
|
||||
if (session.authinfo_user == self.username && session.authinfo_pass == self.password) {
|
||||
if (session.authinfo_user === self.username && session.authinfo_pass === self.password) {
|
||||
session.posting_allowed = true;
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
@@ -157,7 +157,7 @@ class WTVNewsServer {
|
||||
|
||||
getHeader(message, header) {
|
||||
if (message.headers) {
|
||||
const search = Object.keys(message.headers).find(e => (e.toLowerCase() == header.toLowerCase()));
|
||||
const search = Object.keys(message.headers).find(e => (e.toLowerCase() === header.toLowerCase()));
|
||||
if (search) return message.headers[search];
|
||||
}
|
||||
return null;
|
||||
@@ -199,7 +199,7 @@ class WTVNewsServer {
|
||||
let response;
|
||||
if (headers) {
|
||||
Object.keys(headers).forEach((k) => {
|
||||
if (k.toLowerCase() == header.toLowerCase()) {
|
||||
if (k.toLowerCase() === header.toLowerCase()) {
|
||||
response = k;
|
||||
return false;
|
||||
}
|
||||
@@ -315,10 +315,10 @@ class WTVNewsServer {
|
||||
}
|
||||
} else out = { ...meta }
|
||||
|
||||
if (meta.min_index == 0) force_update = true;
|
||||
if (meta.min_index === 0) force_update = true;
|
||||
if (this.featuredGroups) {
|
||||
Object.keys(this.featuredGroups).forEach((k) => {
|
||||
if (group == this.featuredGroups[k].name) {
|
||||
if (group === this.featuredGroups[k].name) {
|
||||
out.wildmat = 'y';
|
||||
out.description = this.featuredGroups[k].description
|
||||
return false;
|
||||
@@ -329,9 +329,9 @@ class WTVNewsServer {
|
||||
if (force_update || this.doesMetaNeedRefreshing(meta)) {
|
||||
out.total = 0;
|
||||
this.fs.readdirSync(g).forEach(file => {
|
||||
if (file == "meta.json") return;
|
||||
if (file === "meta.json") return;
|
||||
const articleNumber = parseInt(file.split('.')[0]);
|
||||
if (out.min_index == 0) out.min_index = articleNumber;
|
||||
if (out.min_index === 0) out.min_index = articleNumber;
|
||||
else if (articleNumber < out.min_index) out.min_index = articleNumber;
|
||||
else if (articleNumber > out.max_index) out.max_index = articleNumber;
|
||||
|
||||
@@ -371,18 +371,18 @@ class WTVNewsServer {
|
||||
try {
|
||||
const articleNumbers = [];
|
||||
this.fs.readdirSync(g).forEach(file => {
|
||||
if (file == "meta.json") return;
|
||||
if (file === "meta.json") return;
|
||||
const articleNumber = parseInt(file.split('.')[0]);
|
||||
articleNumbers.push(articleNumber);
|
||||
});
|
||||
articleNumbers.sort((a, b) => a - b)
|
||||
const index = articleNumbers.findIndex((e) => e == current) - 1;
|
||||
const index = articleNumbers.findIndex((e) => e === current) - 1;
|
||||
if (index >= 0) res = articleNumbers[index];
|
||||
} catch (e) {
|
||||
return e;
|
||||
}
|
||||
if (res) {
|
||||
if (res == current) return null;
|
||||
if (res === current) return null;
|
||||
const message = this.getArticle(group, res);
|
||||
if (message.messageId) {
|
||||
res = { "articleNumber": res, "message_id": message.messageId };
|
||||
@@ -397,12 +397,12 @@ class WTVNewsServer {
|
||||
try {
|
||||
const articleNumbers = [];
|
||||
this.fs.readdirSync(g).forEach(file => {
|
||||
if (file == "meta.json") return;
|
||||
if (file === "meta.json") return;
|
||||
const articleNumber = parseInt(file.split('.')[0]);
|
||||
articleNumbers.push(articleNumber);
|
||||
});
|
||||
articleNumbers.sort((a, b) => a - b)
|
||||
const index = articleNumbers.findIndex((e) => e == current) + 1;
|
||||
const index = articleNumbers.findIndex((e) => e === current) + 1;
|
||||
if (index < articleNumbers.length) res = articleNumbers[index];
|
||||
} catch (e) {
|
||||
return e;
|
||||
@@ -444,11 +444,11 @@ class WTVNewsServer {
|
||||
try {
|
||||
meta = this.getMetadata(group);
|
||||
this.fs.readdirSync(g).forEach(file => {
|
||||
if (file == "meta.json") return;
|
||||
if (file === "meta.json") return;
|
||||
const articleNumber = parseInt(file.split('.')[0]);
|
||||
if (articleNumber < start) return;
|
||||
if (articleNumber > end) return false;
|
||||
if (out.min_index == null) out.min_index = articleNumber;
|
||||
if (out.min_index === null) out.min_index = articleNumber;
|
||||
else if (articleNumber < out.min_index) out.min_index = articleNumber;
|
||||
|
||||
if (articleNumber > out.max_index) out.max_index = articleNumber;
|
||||
|
||||
@@ -16,7 +16,7 @@ class WTVRegister {
|
||||
}
|
||||
|
||||
getServiceOperator(first_letter_lower = false) {
|
||||
if (this.service_owner == "a minisrv user") {
|
||||
if (this.service_owner === "a minisrv user") {
|
||||
if (first_letter_lower) return "the operator of this service";
|
||||
else return "The operator of this service";
|
||||
} else {
|
||||
@@ -45,7 +45,7 @@ class WTVRegister {
|
||||
let available = true;
|
||||
if (this.fs.existsSync(directory)) {
|
||||
this.fs.readdirSync(directory).forEach(file => {
|
||||
if (file.toLowerCase() == ssid.toLowerCase()) {
|
||||
if (file.toLowerCase() === ssid.toLowerCase()) {
|
||||
available = false;
|
||||
return false;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ class WTVRegister {
|
||||
const temp_session_data_file = self.fs.readFileSync(directory + self.path.sep + file, 'Utf8');
|
||||
const temp_session_data = JSON.parse(temp_session_data_file);
|
||||
if (temp_session_data.subscriber_username) {
|
||||
if (temp_session_data.subscriber_username.toLowerCase() == username.toLowerCase()) {
|
||||
if (temp_session_data.subscriber_username.toLowerCase() === username.toLowerCase()) {
|
||||
return_val = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ class WTVShared {
|
||||
* @return {boolean} true if the SSID is valid, false if not
|
||||
*/
|
||||
checkSSID(ssid) {
|
||||
if (ssid.slice(-2) == this.getSSIDCRC(ssid))
|
||||
if (ssid.slice(-2) === this.getSSIDCRC(ssid))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -412,8 +412,8 @@ class WTVShared {
|
||||
exclusiveFilter: (frame) => {
|
||||
let allowed = true;
|
||||
Object.keys(frame.attribs).forEach((k) => {
|
||||
if (k == "href" || k == "background" || k == "src") {
|
||||
allowed = false;
|
||||
if (k === "href" || k === "background" || k === "src") {
|
||||
allowed = false;
|
||||
const value = frame.attribs[k];
|
||||
|
||||
if (frame.tag !== "a") {
|
||||
@@ -1043,7 +1043,7 @@ class WTVShared {
|
||||
new_obj = this.cloneObj(obj)
|
||||
new_obj["wtv-client-serial-number"] = this.censorSSID(new_obj["wtv-client-serial-number"]);
|
||||
}
|
||||
return (new_obj != false) ? new_obj : obj;
|
||||
return (new_obj !== false) ? new_obj : obj;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
@@ -1127,14 +1127,14 @@ class WTVShared {
|
||||
*/
|
||||
getAbsolutePath(path = '', directory = '.') {
|
||||
// Check if directory is already an absolute path
|
||||
if (directory.length > 0 && (directory[0] == "/" || (directory.length >= 3 && directory[1] === ':' && directory[2] === this.path.sep))) {
|
||||
if (directory.length > 0 && (directory[0] === "/" || (directory.length >= 3 && directory[1] === ':' && directory[2] === this.path.sep))) {
|
||||
return this.path.resolve(directory + this.path.sep + path);
|
||||
}
|
||||
try {
|
||||
// start with our absolute path (of app.js)
|
||||
const appdir = this.path.resolve(__dirname + this.path.sep + '..' + this.path.sep + '..')
|
||||
|
||||
if (path == '' && directory == '.') {
|
||||
if (path === '' && directory === '.') {
|
||||
return appdir;
|
||||
}
|
||||
// If the directory is a valid directory, prepend it to the path
|
||||
@@ -1252,7 +1252,7 @@ class WTVShared {
|
||||
|
||||
if (overrides.exceptions) {
|
||||
Object.keys(overrides.exceptions).forEach((j) => {
|
||||
if (k != overrides.exceptions[j]) out += self.minisrv_config.services[k].toString(overrides) + "\n";
|
||||
if (k !== overrides.exceptions[j]) out += self.minisrv_config.services[k].toString(overrides) + "\n";
|
||||
});
|
||||
} else {
|
||||
out += self.minisrv_config.services[k].toString(overrides) + "\n";
|
||||
|
||||
@@ -41,7 +41,7 @@ class WTVShenanigans {
|
||||
|
||||
// shenanigans are enabled, so check if the requested shenanigan is within the level enabled
|
||||
Object.keys(shenanigans).forEach((k) => {
|
||||
if (shenanigans[k] == value) {
|
||||
if (shenanigans[k] === value) {
|
||||
if (level >= shenanigans[k]) {
|
||||
retval = true;
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user