option for more emails,fix jmap service,add table email accounts

This commit is contained in:
richardtekula
2025-11-19 13:15:45 +01:00
parent 97f437c1c4
commit 1e7c1eab90
18 changed files with 1991 additions and 1299 deletions

View File

@@ -21,6 +21,19 @@ export const users = pgTable('users', {
updatedAt: timestamp('updated_at').defaultNow().notNull(),
});
// Email Accounts table - viacero emailových účtov pre jedného usera
export const emailAccounts = pgTable('email_accounts', {
id: uuid('id').primaryKey().defaultRandom(),
userId: uuid('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(),
email: text('email').notNull(),
emailPassword: text('email_password').notNull(), // Heslo k emailovému účtu (encrypted)
jmapAccountId: text('jmap_account_id').notNull(), // JMAP account ID z truemail
isPrimary: boolean('is_primary').default(false).notNull(), // primárny email účet
isActive: boolean('is_active').default(true).notNull(), // či je účet aktívny
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
});
// Audit logs - kompletný audit trail všetkých akcií
export const auditLogs = pgTable('audit_logs', {
id: uuid('id').primaryKey().defaultRandom(),
@@ -41,6 +54,7 @@ export const auditLogs = pgTable('audit_logs', {
export const contacts = pgTable('contacts', {
id: uuid('id').primaryKey().defaultRandom(),
userId: uuid('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(),
emailAccountId: uuid('email_account_id').references(() => emailAccounts.id, { onDelete: 'cascade' }).notNull(),
email: text('email').notNull(),
name: text('name'),
notes: text('notes'),
@@ -53,6 +67,7 @@ export const contacts = pgTable('contacts', {
export const emails = pgTable('emails', {
id: uuid('id').primaryKey().defaultRandom(),
userId: uuid('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(),
emailAccountId: uuid('email_account_id').references(() => emailAccounts.id, { onDelete: 'cascade' }).notNull(),
contactId: uuid('contact_id').references(() => contacts.id, { onDelete: 'cascade' }),
jmapId: text('jmap_id').unique(),
messageId: text('message_id').unique(),