email: store emails.db per account under email_accounts/<account>/
Reorganizes email storage: the DB moves from DATA_PATH/<user>/emails.db to DATA_PATH/<user>/email_accounts/<accountEmail>/emails.db, with a shared email_accounts/attachment_cache/ (was Gmail/emails/attachments). openEmailDb now takes (owner, account); a new openUserEmailDb(owner, userId) resolves the user's configured account (first enabled) for read paths. Threads the account through email.ts, accounts, resync, queue sync, channel handlers, and the email_db MCP tool path. Drops the dead getUserEmailDir helper. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,7 @@ import { SANDBOX_DATA } from '../sandbox';
|
||||
import * as claudeManager from './claude-manager';
|
||||
import { createSidecarConnector } from '../connect';
|
||||
import { sign } from '../../jwt';
|
||||
import { getUserByEmail } from 'officerdb';
|
||||
import { getUserByEmail, getEmailAccounts } from 'officerdb';
|
||||
|
||||
const email = process.env.CLAUDE_USER_EMAIL;
|
||||
if (!email) {
|
||||
@@ -38,6 +38,10 @@ const OFFICER_AUTH_TOKEN = await sign(
|
||||
const homeDir =
|
||||
dbUser.role === 'Super Admin' ? (process.env.HOME_DIR ?? homedir()) : join(DATA_PATH, email, 'home');
|
||||
const globalToolsDir = join(DATA_PATH, 'tools');
|
||||
|
||||
// The email_db MCP tool reads one account's SQLite store; use the user's first configured account.
|
||||
const emailAccounts = await getEmailAccounts(dbUser.id);
|
||||
const emailDbRel = join('email_accounts', emailAccounts[0]?.email ?? 'none', 'emails.db');
|
||||
const userToolsDir = join(DATA_PATH, email, 'tools');
|
||||
|
||||
// ── Path setup ──
|
||||
@@ -90,7 +94,7 @@ function generateMcpConfig(): McpPaths {
|
||||
args: ['run', MCP_SERVER_SCRIPT],
|
||||
env: {
|
||||
PI_TOOLS_DIRS: sandboxToolsDirs,
|
||||
OFFICER_EMAIL_DB: `${SANDBOX_DATA}/emails.db`,
|
||||
OFFICER_EMAIL_DB: `${SANDBOX_DATA}/${emailDbRel}`,
|
||||
MCP_TOOLS_LOG: `${SANDBOX_DATA}/logs/mcp-tools.log`,
|
||||
OFFICER_API_URL,
|
||||
OFFICER_AUTH_TOKEN,
|
||||
@@ -110,7 +114,7 @@ function generateMcpConfig(): McpPaths {
|
||||
args: ['run', MCP_SERVER_SCRIPT],
|
||||
env: {
|
||||
PI_TOOLS_DIRS: hostToolsDirs,
|
||||
OFFICER_EMAIL_DB: join(userRoot, 'emails.db'),
|
||||
OFFICER_EMAIL_DB: join(userRoot, emailDbRel),
|
||||
MCP_TOOLS_LOG: join(userRoot, 'logs', 'mcp-tools.log'),
|
||||
OFFICER_API_URL,
|
||||
OFFICER_AUTH_TOKEN,
|
||||
|
||||
Reference in New Issue
Block a user