From caf265e7050edefa64ecf7e13828ec9636bce867 Mon Sep 17 00:00:00 2001 From: Bobby Date: Sun, 8 Mar 2026 03:06:23 +0530 Subject: Refactor configuration handling and add mail management features - Removed dependency on messages package in TOML loading and parsing. - Introduced new config constants and messages for better clarity and maintainability. - Implemented mail user and mailbox management with corresponding controllers and views. - Added new templates for mailboxes, mailbox creation, and user management. - Enhanced logging and error handling throughout the application. - Established a structured approach for applying default values in TOML configuration. - Created new utility functions for SMTP and email handling. --- database/functions.go | 22 ---------------------- database/migration.go | 16 ++++++++-------- database/resolve.go | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 30 deletions(-) delete mode 100644 database/functions.go create mode 100644 database/resolve.go (limited to 'database') diff --git a/database/functions.go b/database/functions.go deleted file mode 100644 index 09d6ae4..0000000 --- a/database/functions.go +++ /dev/null @@ -1,22 +0,0 @@ -package database - -import ( - "path/filepath" - - "dove/config" - - "gorm.io/gorm/logger" -) - -func resolveDatabasePath() string { - return filepath.Join(config.DataDir, FileName) -} - -func resolveGORMLogLevel() logger.Interface { - switch config.Server.Debug { - case true: - return logger.Default.LogMode(logger.Info) - default: - return logger.Default.LogMode(logger.Silent) - } -} diff --git a/database/migration.go b/database/migration.go index e18f2d6..efd3aba 100644 --- a/database/migration.go +++ b/database/migration.go @@ -1,8 +1,8 @@ package database import ( - "dove/models" "dove/models/domain" + "dove/models/mail" "dove/utils/logger" ) @@ -10,15 +10,15 @@ func migrate() { migrationError := DB.AutoMigrate( &domain.TLD{}, &domain.Domain{}, - &models.User{}, - &models.Mailbox{}, - &models.Alias{}, - &models.Email{}, - &models.Tag{}, - &models.Attachment{}, + &mail.User{}, + &mail.Mailbox{}, + &mail.Alias{}, + &mail.Email{}, + &mail.Tag{}, + &mail.Attachment{}, ) if migrationError != nil { logger.Fatalf(LogPrefix, MigrationFailed, migrationError) } -} +} \ No newline at end of file diff --git a/database/resolve.go b/database/resolve.go new file mode 100644 index 0000000..db90dc5 --- /dev/null +++ b/database/resolve.go @@ -0,0 +1,22 @@ +package database + +import ( + "path/filepath" + + "dove/config" + + "gorm.io/gorm/logger" +) + +func resolveDatabasePath() string { + return filepath.Join(config.DataDir, FileName) +} + +func resolveGORMLogLevel() logger.Interface { + switch config.HTTP.Debug { + case true: + return logger.Default.LogMode(logger.Info) + default: + return logger.Default.LogMode(logger.Silent) + } +} \ No newline at end of file -- cgit v1.2.3