sync flags on server start

This commit is contained in:
grimhilt
2023-04-17 13:08:54 +02:00
parent 0f063deff9
commit cd996d851a
3 changed files with 64 additions and 19 deletions

View File

@@ -16,26 +16,38 @@ export async function getAllAccounts() {
return await execQueryAsync(query, values);
}
export async function getAllMailboxes(accountId) {
const query = 'SELECT * FROM mailbox WHERE mailbox.account_id = ?';
export async function getAllMailboxes(accountId: number) {
const query = "SELECT * FROM mailbox WHERE mailbox.account_id = ?";
const values = [accountId];
return await execQueryAsync(query, values)
return await execQueryAsync(query, values);
}
export async function registerMailbox(accountId, mailboxName) {
export async function registerMailbox(accountId: number, mailboxName: string) {
const query = `INSERT INTO mailbox (account_id, mailbox_name) VALUES (?, ?)`;
const values = [accountId, mailboxName];
return await execQueryAsyncWithId(query, values);
}
export async function getMailbox(mailboxId) {
export async function getMailbox(mailboxId: number) {
const query = `SELECT * FROM mailbox WHERE mailbox_id = ?`;
const values = [mailboxId];
return await execQueryAsync(query, values);
}
export function updateMailbox(mailboxId, uidnext) {
export function updateMailbox(mailboxId: number, uidnext: number) {
const query = `UPDATE mailbox SET uidnext = ? WHERE mailbox_id = ?`;
const values = [uidnext, mailboxId];
execQuery(query, values);
}
}
export async function updateMailboxModseq(mailboxId: number, modseq: number) {
const query = `UPDATE mailbox SET nextmodseq = ? WHERE mailbox_id = ?`;
const values = [modseq, mailboxId];
return await execQueryAsync(query, values);
}
export async function getMailboxModseq(mailboxId: number): Promise<{ modseq: number }[]> {
const query = `SELECT nextmodseq AS modseq FROM mailbox WHERE mailbox_id = ?`;
const values = [mailboxId];
return await execQueryAsync(query, values);
}