Initial Email-Forwarder scaffold
This commit is contained in:
commit
91e52aecd0
22 changed files with 1007 additions and 0 deletions
59
backend/02-database.go
Normal file
59
backend/02-database.go
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
package backend
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
var DB *sql.DB
|
||||
|
||||
// Account = eine Umzugs-Zeile: Quelle (alt) -> Ziel (neu), frei gemapptes
|
||||
// Zieladress-Postfach. Wird im Browser gepflegt (Tabelle accounts).
|
||||
type Account struct {
|
||||
ID int64
|
||||
Name string // z.B. "hans-peter"
|
||||
// Quelle (alter Provider). Security: "tls" (implizit, 993/995),
|
||||
// "starttls" (Klartext-Port 143/110 + Upgrade), "none" (reiner Klartext).
|
||||
// SrcInsecure = ungueltige/selbstsignierte Zerts akzeptieren (alte Hoster).
|
||||
SrcHost string
|
||||
SrcPort int
|
||||
SrcSecurity string
|
||||
SrcInsecure bool
|
||||
SrcUser string // hans-peter@dr-gold.de
|
||||
SrcPass string
|
||||
SrcProto string // "imap" (default) oder "pop3" (Fallback-Quelle)
|
||||
// Ziel (neuer Provider). Meist "tls"; "none"/"starttls" ebenso moeglich.
|
||||
DstHost string
|
||||
DstPort int
|
||||
DstSecurity string
|
||||
DstInsecure bool
|
||||
DstUser string // archiv-hans-peter@dr-gold.com
|
||||
DstPass string
|
||||
MboxDir string // Unterordner unter Cfg.MboxRoot; leer = Cfg.MboxRoot/Name
|
||||
Active bool
|
||||
}
|
||||
|
||||
// ConnectDB oeffnet die SQLite-DB (modernc, kein cgo) und legt das Schema an.
|
||||
//
|
||||
// Schema (TODO Codex):
|
||||
//
|
||||
// accounts(...) -- die Umzugs-Zeilen (oben), inkl.
|
||||
// src_security/src_insecure etc.
|
||||
// folder_map(account_id, src, dst) -- optionales manuelles Umbenennen
|
||||
// (Vorrang vor der Rollen-Automatik
|
||||
// aus 11-folders.go)
|
||||
// copied(account_id, folder, message_id) -- Idempotenz-/Delta-Cache: schon
|
||||
// kopierte Message-IDs, UNIQUE.
|
||||
// Zweiter Lauf kopiert nur das Delta.
|
||||
// jobs(account_id, started, finished, -- Lauf-Historie fuer den Fortschritt
|
||||
// total, done, errors, state) im Browser.
|
||||
func ConnectDB() error {
|
||||
// TODO Codex: sql.Open("sqlite", Cfg.DBPath), PRAGMA journal_mode=WAL,
|
||||
// CREATE TABLE IF NOT EXISTS ... siehe Schema oben.
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO Codex: ListAccounts / SaveAccount / DeleteAccount / GetAccount,
|
||||
// AlreadyCopied(accountID, folder, messageID) bool,
|
||||
// MarkCopied(accountID, folder, messageID).
|
||||
Loading…
Add table
Add a link
Reference in a new issue