fix(imap-idle): use snake_case table + columns (match Prisma @map)
Daemon SQL used PascalCase "MailConnection" + camelCase column-names that match the Prisma model field-names — but actual DB has snake_case table "mail_connections" with snake_case columns (per @map decorators). Result: daemon was online but ALL queries failed with relation "rebreak.MailConnection" does not exist → no mailboxes loaded → no IDLE-sessions established. Fix: query "rebreak.mail_connections" with snake_case columns, alias back to camelCase via SQL AS so rest of the daemon code works unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
343a25bc05
commit
fd737f8658
@ -44,11 +44,19 @@ const RECONNECT_LOOP_DELAY_MS = 60 * 1000;
|
||||
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
|
||||
|
||||
async function loadActiveConnections() {
|
||||
// DB-table heißt "mail_connections" + snake_case columns (Prisma @map).
|
||||
// Aliase auf camelCase damit der restliche Daemon-Code unverändert bleibt.
|
||||
const { rows } = await pool.query(
|
||||
`SELECT id, "userId", email, "imapHost", "imapPort",
|
||||
"passwordEncrypted", "rejectUnauthorized", "useStarttls"
|
||||
FROM rebreak."MailConnection"
|
||||
WHERE "isActive" = true`,
|
||||
`SELECT id,
|
||||
user_id AS "userId",
|
||||
email,
|
||||
imap_host AS "imapHost",
|
||||
imap_port AS "imapPort",
|
||||
password_encrypted AS "passwordEncrypted",
|
||||
reject_unauthorized AS "rejectUnauthorized",
|
||||
use_starttls AS "useStarttls"
|
||||
FROM rebreak.mail_connections
|
||||
WHERE is_active = true`,
|
||||
);
|
||||
return rows;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user