From 2f0a1eba33e7f13fb6b403165b87b60906b4ad61 Mon Sep 17 00:00:00 2001 From: zefie Date: Fri, 8 Aug 2025 23:04:34 -0400 Subject: [PATCH] fix could not send mail --- .../includes/classes/WTVClientSessionData.js | 8 ++++++- .../includes/classes/WTVMail.js | 7 ++++--- .../includes/classes/WTVShared.js | 21 +++++++++++-------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/zefie_wtvp_minisrv/includes/classes/WTVClientSessionData.js b/zefie_wtvp_minisrv/includes/classes/WTVClientSessionData.js index e3bf65e7..5dcefac5 100644 --- a/zefie_wtvp_minisrv/includes/classes/WTVClientSessionData.js +++ b/zefie_wtvp_minisrv/includes/classes/WTVClientSessionData.js @@ -232,8 +232,14 @@ class WTVClientSessionData { getUserStoreDirectory(subscriber = false, user_id = null) { if (user_id === null) user_id = this.user_id; var userstore = this.getAccountStoreDirectory() + this.path.sep + this.ssid + this.path.sep; + console.log("DEBUG: getAccountStoreDirectory() =", this.getAccountStoreDirectory()); + console.log("DEBUG: userstore before getAbsolutePath =", userstore); if (!subscriber) userstore += "user" + user_id + this.path.sep; - return this.wtvshared.getAbsolutePath(userstore) + this.path.sep; + console.log("DEBUG: userstore after user_id =", userstore); + // getAccountStoreDirectory() already returns an absolute path, so we don't need getAbsolutePath again + var result = userstore + this.path.sep; + console.log("DEBUG: final result =", result); + return result; } removeUser(user_id) { diff --git a/zefie_wtvp_minisrv/includes/classes/WTVMail.js b/zefie_wtvp_minisrv/includes/classes/WTVMail.js index c4487dc5..911de93c 100644 --- a/zefie_wtvp_minisrv/includes/classes/WTVMail.js +++ b/zefie_wtvp_minisrv/includes/classes/WTVMail.js @@ -60,7 +60,6 @@ class WTVMail { if (this.mailstore_dir === null) { // set mailstore directory local var so we don't call the function every time var userstore_dir = this.wtvclient.getUserStoreDirectory(); - // MailStore var store_dir = "MailStore" + this.path.sep; this.mailstore_dir = userstore_dir + store_dir; @@ -376,7 +375,7 @@ class WTVMail { checkUserExists(username, directory = null) { // returns the user's ssid, and user_id and userid in an array if true, false if not - var search_dir = this.path.resolve(this.wtvshared.getAbsolutePath() + this.path.sep + this.minisrv_config.config.SessionStore); + var search_dir = this.wtvshared.getAbsolutePath(this.minisrv_config.config.SessionStore + this.path.sep + "accounts"); var return_val = false; var self = this; if (directory) search_dir = directory; @@ -390,7 +389,9 @@ class WTVMail { var temp_session_data = JSON.parse(temp_session_data_file); if (temp_session_data.subscriber_username) { if (temp_session_data.subscriber_username.toLowerCase() == username.toLowerCase()) { - return_val = search_dir.replace(this.minisrv_config.config.SessionStore + self.path.sep + "accounts" + self.path.sep, '').replace("user", '').split(self.path.sep); + // Use the absolute path for replacement since search_dir is now absolute + var accounts_dir = self.wtvshared.getAbsolutePath(self.minisrv_config.config.SessionStore + self.path.sep + "accounts" + self.path.sep); + return_val = search_dir.replace(accounts_dir, '').replace("user", '').split(self.path.sep); return_val.push(temp_session_data.subscriber_name); } } diff --git a/zefie_wtvp_minisrv/includes/classes/WTVShared.js b/zefie_wtvp_minisrv/includes/classes/WTVShared.js index 5055981a..cfcae873 100644 --- a/zefie_wtvp_minisrv/includes/classes/WTVShared.js +++ b/zefie_wtvp_minisrv/includes/classes/WTVShared.js @@ -1154,7 +1154,8 @@ class WTVShared { * @param {string} directory Root directory */ getAbsolutePath(path = '', directory = '.') { - if (directory[0] == "/" || directory.slice(1, 3) == ":" + this.path.sep) { + // Check if directory is already an absolute path + 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 { @@ -1165,22 +1166,24 @@ class WTVShared { return appdir; } // If the directory is a valid directory, prepend it to the path - directory = this.path.resolve(appdir + this.path.sep + directory); + let resolvedDirectory = this.path.resolve(appdir + this.path.sep + directory); if (!path) { - return directory; + return resolvedDirectory; } - if (directory && !path.startsWith(directory)) { - if (!directory.endsWith(this.path.sep)) { - directory += this.path.sep; + if (resolvedDirectory && !path.startsWith(resolvedDirectory)) { + if (!resolvedDirectory.endsWith(this.path.sep)) { + resolvedDirectory += this.path.sep; } - path = directory + path; + path = resolvedDirectory + path; } + // The path.resolve method will take care of normalizing slashes + return this.path.resolve(path); } catch (e) { // If there's an error accessing the directory, log it or handle as needed console.error('Error resolving directory:', e); + // Fallback to basic path resolution + return this.path.resolve(path); } - // The path.resolve method will take care of normalizing slashes - return this.path.resolve(path); } /**