Refactoring finalised ... I think.

This commit is contained in:
2025-04-23 11:30:03 +01:00
parent e938828a8c
commit f9853c921d
3 changed files with 13 additions and 1 deletions

View File

@@ -47,6 +47,7 @@ func MessagesInboxHandler(db *sql.DB) http.HandlerFunc {
tmpl := templateHelpers.LoadTemplateFiles("messages.html", "templates/account/messages/index.html") tmpl := templateHelpers.LoadTemplateFiles("messages.html", "templates/account/messages/index.html")
if err := tmpl.ExecuteTemplate(w, "layout", context); err != nil { if err := tmpl.ExecuteTemplate(w, "layout", context); err != nil {
// ToDo: Make this load all error pages without defining explictly.
templateHelpers.RenderError(w, r, 500) templateHelpers.RenderError(w, r, 500)
} }
} }

View File

@@ -15,7 +15,7 @@ var db *sql.DB
func InitDB(filepath string) *sql.DB { func InitDB(filepath string) *sql.DB {
var err error var err error
cfg := config.Get() cfg := config.Get()
db, err := sql.Open("sqlite", filepath) db, err = sql.Open("sqlite", filepath)
if err != nil { if err != nil {
log.Fatal("❌ Failed to open DB:", err) log.Fatal("❌ Failed to open DB:", err)
} }
@@ -29,6 +29,7 @@ func InitDB(filepath string) *sql.DB {
SchemaUsersMessages, SchemaUsersMessages,
SchemaUsersNotifications, SchemaUsersNotifications,
SchemaAuditLog, SchemaAuditLog,
SchemaAuditLogin,
SchemaLogTicketMatching, SchemaLogTicketMatching,
SchemaAdminAccessLog, SchemaAdminAccessLog,
SchemaNewAuditLog, SchemaNewAuditLog,

View File

@@ -175,6 +175,16 @@ CREATE TABLE IF NOT EXISTS audit_log (
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
);` );`
const SchemaAuditLogin = `
CREATE TABLE IF NOT EXISTS audit_login (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT,
success BOOLEAN,
ip TEXT,
user_agent TEXT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
);`
const SchemaSyndicates = ` const SchemaSyndicates = `
CREATE TABLE IF NOT EXISTS syndicates ( CREATE TABLE IF NOT EXISTS syndicates (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,