fix could not send mail

This commit is contained in:
zefie
2025-08-08 23:04:34 -04:00
parent 11997228f9
commit 2f0a1eba33
3 changed files with 23 additions and 13 deletions

View File

@@ -232,8 +232,14 @@ class WTVClientSessionData {
getUserStoreDirectory(subscriber = false, user_id = null) { getUserStoreDirectory(subscriber = false, user_id = null) {
if (user_id === null) user_id = this.user_id; if (user_id === null) user_id = this.user_id;
var userstore = this.getAccountStoreDirectory() + this.path.sep + this.ssid + this.path.sep; 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; 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) { removeUser(user_id) {

View File

@@ -60,7 +60,6 @@ class WTVMail {
if (this.mailstore_dir === null) { if (this.mailstore_dir === null) {
// set mailstore directory local var so we don't call the function every time // set mailstore directory local var so we don't call the function every time
var userstore_dir = this.wtvclient.getUserStoreDirectory(); var userstore_dir = this.wtvclient.getUserStoreDirectory();
// MailStore // MailStore
var store_dir = "MailStore" + this.path.sep; var store_dir = "MailStore" + this.path.sep;
this.mailstore_dir = userstore_dir + store_dir; this.mailstore_dir = userstore_dir + store_dir;
@@ -376,7 +375,7 @@ class WTVMail {
checkUserExists(username, directory = null) { checkUserExists(username, directory = null) {
// returns the user's ssid, and user_id and userid in an array if true, false if not // 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 return_val = false;
var self = this; var self = this;
if (directory) search_dir = directory; if (directory) search_dir = directory;
@@ -390,7 +389,9 @@ class WTVMail {
var temp_session_data = JSON.parse(temp_session_data_file); var temp_session_data = JSON.parse(temp_session_data_file);
if (temp_session_data.subscriber_username) { 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 = 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); return_val.push(temp_session_data.subscriber_name);
} }
} }

View File

@@ -1154,7 +1154,8 @@ class WTVShared {
* @param {string} directory Root directory * @param {string} directory Root directory
*/ */
getAbsolutePath(path = '', 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); return this.path.resolve(directory + this.path.sep + path);
} }
try { try {
@@ -1165,22 +1166,24 @@ class WTVShared {
return appdir; return appdir;
} }
// If the directory is a valid directory, prepend it to the path // 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) { if (!path) {
return directory; return resolvedDirectory;
} }
if (directory && !path.startsWith(directory)) { if (resolvedDirectory && !path.startsWith(resolvedDirectory)) {
if (!directory.endsWith(this.path.sep)) { if (!resolvedDirectory.endsWith(this.path.sep)) {
directory += this.path.sep; resolvedDirectory += this.path.sep;
} }
path = directory + path; path = resolvedDirectory + path;
}
} catch (e) {
// If there's an error accessing the directory, log it or handle as needed
console.error('Error resolving directory:', e);
} }
// The path.resolve method will take care of normalizing slashes // The path.resolve method will take care of normalizing slashes
return this.path.resolve(path); 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);
}
} }
/** /**