Add instance settings and mail delivery through PocketBase

Superadmins can now change signup rules (on/off and the domain allow-list)
and branding at runtime; the environment variables only seed the defaults.
Mail and S3 storage settings pass through to PocketBase's own settings, and
docwell-server sends its own emails through a PocketBase hook so there is a
single SMTP configuration. The boot hook no longer wipes SMTP settings that
were not set from the environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-10-31 16:22:53 +01:00
1 parent ba394b8fac
commit e33a99241e
21 files changed
+1714 -25

No files matched your search

+9 -1
View File
@@ -21,6 +21,8 @@ import (
"docwell/server/internal/config"
"docwell/server/internal/directory"
"docwell/server/internal/httpapi"
"docwell/server/internal/mail"
"docwell/server/internal/settings"
"docwell/server/internal/store/pocketbase"
"docwell/server/internal/ycrdt"
)
@@ -43,7 +45,12 @@ func run(log *slog.Logger) error {
}
db := pocketbase.New(cfg.PocketBaseURL, cfg.PocketBaseEmail, cfg.PocketBasePassword)
authSvc := auth.NewService(db, auth.Options{SignupEnabled: cfg.SignupEnabled, SignupDomains: cfg.SignupDomains})
mailer := mail.PBSender{PB: db}
settingsSvc := settings.New(db, settings.Signup{Enabled: cfg.SignupEnabled, Domains: cfg.SignupDomains}, mailer)
authSvc := auth.NewService(db, auth.Options{Rules: func(ctx context.Context) (bool, []string, error) {
rules, err := settingsSvc.Signup(ctx)
return rules.Enabled, rules.Domains, err
}})
// yrs.wasm compiles once; the cache makes later starts fast (ADR-3).
cacheDir, _ := os.UserCacheDir()
@@ -67,6 +74,7 @@ func run(log *slog.Logger) error {
DB: db,
Auth: authSvc,
Directory: dirSvc,
Settings: settingsSvc,
Collab: hub,
Admin: admin.Handler("/admin"),
Log: log,