@bobfrankston/mailx 1.0.141 → 1.0.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/mailx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.143",
|
|
4
4
|
"description": "Local-first email client with IMAP sync and standalone native app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "bin/mailx.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@bobfrankston/iflow": "^1.0.52",
|
|
24
24
|
"@bobfrankston/miscinfo": "^1.0.7",
|
|
25
25
|
"@bobfrankston/oauthsupport": "^1.0.20",
|
|
26
|
-
"@bobfrankston/msger": "^0.1.
|
|
26
|
+
"@bobfrankston/msger": "^0.1.196",
|
|
27
27
|
"@capacitor/android": "^8.3.0",
|
|
28
28
|
"@capacitor/cli": "^8.3.0",
|
|
29
29
|
"@capacitor/core": "^8.3.0",
|
|
@@ -150,7 +150,31 @@ export function createApiRouter(db, imapManager) {
|
|
|
150
150
|
if (detected?.cloud) {
|
|
151
151
|
await initCloudConfig(detected.cloud);
|
|
152
152
|
}
|
|
153
|
-
//
|
|
153
|
+
// Check if cloud config found existing accounts (e.g., from GDrive mount or API)
|
|
154
|
+
let accounts = loadAccounts();
|
|
155
|
+
if (accounts.length === 0) {
|
|
156
|
+
accounts = await loadAccountsAsync();
|
|
157
|
+
}
|
|
158
|
+
if (accounts.length > 0) {
|
|
159
|
+
// Existing accounts found on cloud — use them, don't create new
|
|
160
|
+
console.log(` Found ${accounts.length} existing account(s) from cloud settings`);
|
|
161
|
+
const settings = loadSettings();
|
|
162
|
+
for (const acct of settings.accounts) {
|
|
163
|
+
if (!acct.enabled)
|
|
164
|
+
continue;
|
|
165
|
+
try {
|
|
166
|
+
await imapManager.addAccount(acct);
|
|
167
|
+
console.log(` Account loaded: ${acct.label || acct.name} (${acct.id})`);
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
console.error(` Account ${acct.id} error: ${e.message}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
imapManager.syncAll().catch(() => { });
|
|
174
|
+
res.json({ ok: true, message: `Loaded ${accounts.length} existing account(s) from cloud settings.` });
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
// No existing accounts — build new account config
|
|
154
178
|
const account = { email, name: name || email.split("@")[0] };
|
|
155
179
|
if (password)
|
|
156
180
|
account.password = password;
|
|
@@ -159,11 +183,6 @@ export function createApiRouter(db, imapManager) {
|
|
|
159
183
|
account.imap = { host: detected.imapHost, port: 993, tls: true, auth: detected.auth, user: email };
|
|
160
184
|
account.smtp = { host: detected.smtpHost, port: 587, tls: true, auth: detected.auth, user: email };
|
|
161
185
|
}
|
|
162
|
-
// Load existing accounts — try cloud API in case home/.mailx already exists on Drive
|
|
163
|
-
let accounts = loadAccounts();
|
|
164
|
-
if (accounts.length === 0) {
|
|
165
|
-
accounts = await loadAccountsAsync();
|
|
166
|
-
}
|
|
167
186
|
const id = domain.split(".")[0] || "account";
|
|
168
187
|
if (accounts.some((a) => a.email === email)) {
|
|
169
188
|
res.json({ ok: false, error: "Account already exists" });
|
|
@@ -91,7 +91,9 @@ export { getSharedDir };
|
|
|
91
91
|
/** Initialize local config if it doesn't exist */
|
|
92
92
|
export declare function initLocalConfig(sharedDir?: string, storePath?: string): void;
|
|
93
93
|
/** Initialize config with Google Drive cloud storage.
|
|
94
|
-
* Finds or creates the app-owned "mailx" folder
|
|
94
|
+
* Finds or creates the app-owned "mailx" folder via Drive API and stores its ID.
|
|
95
|
+
* No mount scanning — API only. Existing settings at other paths (e.g., home/.mailx
|
|
96
|
+
* from Desktop sync) must be migrated manually or via config.jsonc importPath. */
|
|
95
97
|
export declare function initCloudConfig(provider?: "gdrive"): Promise<void>;
|
|
96
98
|
declare const DEFAULT_SETTINGS: MailxSettings;
|
|
97
99
|
/** Get historyDays for an account: per-account override > system override > shared default */
|
|
@@ -548,22 +548,19 @@ export function initLocalConfig(sharedDir, storePath) {
|
|
|
548
548
|
atomicWrite(LOCAL_CONFIG_PATH, config);
|
|
549
549
|
}
|
|
550
550
|
/** Initialize config with Google Drive cloud storage.
|
|
551
|
-
* Finds or creates the app-owned "mailx" folder
|
|
551
|
+
* Finds or creates the app-owned "mailx" folder via Drive API and stores its ID.
|
|
552
|
+
* No mount scanning — API only. Existing settings at other paths (e.g., home/.mailx
|
|
553
|
+
* from Desktop sync) must be migrated manually or via config.jsonc importPath. */
|
|
552
554
|
export async function initCloudConfig(provider = "gdrive") {
|
|
553
555
|
const existing = readLocalConfig();
|
|
554
556
|
if (existing.sharedDir)
|
|
555
557
|
return; // Already configured
|
|
556
|
-
// Find or create the "mailx" folder
|
|
558
|
+
// Find or create the "mailx" folder via Drive API
|
|
557
559
|
const folderId = await gDriveFindOrCreateFolder();
|
|
558
560
|
const sharedDir = { provider, path: "mailx", folderId: folderId || undefined };
|
|
559
|
-
const config = {
|
|
560
|
-
...existing,
|
|
561
|
-
sharedDir: sharedDir,
|
|
562
|
-
storePath: existing.storePath || DEFAULT_STORE_PATH,
|
|
563
|
-
};
|
|
561
|
+
const config = { ...existing, sharedDir, storePath: existing.storePath || DEFAULT_STORE_PATH };
|
|
564
562
|
fs.mkdirSync(LOCAL_DIR, { recursive: true });
|
|
565
563
|
atomicWrite(LOCAL_CONFIG_PATH, config);
|
|
566
|
-
// Set up cloud API fallback immediately
|
|
567
564
|
pendingCloudConfig = sharedDir;
|
|
568
565
|
console.log(` Initialized cloud config: ${provider} (folder ID: ${folderId || "pending"})`);
|
|
569
566
|
}
|