import { execQueryAsyncWithId, execQueryAsync, execQuery } from "../db"; export async function getAllAccounts() { const query = ` SELECT app_account.account_id AS id, address.email AS user, app_account.account_pwd AS password, app_account.host AS host, app_account.port AS port, app_account.tls AS tls FROM app_account INNER JOIN address WHERE address.address_id = app_account.user_id `; const values = []; return await execQueryAsync(query, values); } export async function getAllMailboxes(accountId) { const query = 'SELECT * FROM mailbox WHERE mailbox.account_id = ?'; const values = [accountId]; return await execQueryAsync(query, values) } export async function registerMailbox(accountId, mailboxName) { const query = `INSERT INTO mailbox (account_id, mailbox_name) VALUES (?, ?)`; const values = [accountId, mailboxName]; return await execQueryAsyncWithId(query, values); } export async function getMailbox(mailboxId) { const query = `SELECT * FROM mailbox WHERE mailbox_id = ?`; const values = [mailboxId]; return await execQueryAsync(query, values); } export function updateMailbox(mailboxId, uidnext) { const query = `UPDATE mailbox SET uidnext = ? WHERE mailbox_id = ?`; const values = [uidnext, mailboxId]; execQuery(query, values); }