Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review: include accountId in getMessage, emit failed for non-success sync
Adam Eivy34bee00f32b3
diff --git a/server/services/messageSync.js b/server/services/messageSync.jsindex 6648a77394..f6e7dfa064 100644--- a/server/services/messageSync.js+++ b/server/services/messageSync.js@@ -3,6 +3,7 @@ import { join } from 'path';import { ensureDir, PATHS, safeJSONParse } from '../lib/fileUtils.js';import { getAccount, updateSyncStatus } from './messageAccounts.js';+// TODO: Add unit tests for getMessages, syncAccount (cache, dedup, locking, status)const CACHE_DIR = join(PATHS.messages, 'cache');const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;const syncLocks = new Map();@@ -83,7 +84,9 @@ export async function deleteCache(accountId) {export async function getMessage(accountId, messageId) {const cache = await loadCache(accountId);- return cache.messages.find(m => m.id === messageId) || null;+ const msg = cache.messages.find(m => m.id === messageId);+ if (!msg) return null;+ return { ...msg, accountId: msg.accountId || accountId };}export async function syncAccount(accountId, io) {@@ -128,8 +131,12 @@ export async function syncAccount(accountId, io) {await saveCache(accountId, cache);await updateSyncStatus(accountId, providerStatus === 'success' ? 'success' : providerStatus);- io?.emit('messages:sync:completed', { accountId, newMessages: uniqueNew.length, status: providerStatus });- io?.emit('messages:changed', {});+ if (providerStatus === 'success') {+ io?.emit('messages:sync:completed', { accountId, newMessages: uniqueNew.length, status: providerStatus });+ io?.emit('messages:changed', {});+ } else {+ io?.emit('messages:sync:failed', { accountId, error: `Sync finished with status: ${providerStatus}`, status: providerStatus });+ }console.log(`📧 Sync complete for ${account.name}: ${uniqueNew.length} new, status=${providerStatus}`);return { newMessages: uniqueNew.length, total: cache.messages.length, status: providerStatus };