Send reply mail from the post event bus (#16)

Stacks on #15. Handlers only persist and publish; a mail subscriber sends reply email. Unset Resend stays a no-op.

Reviewed-on: #16
Co-authored-by: codegirl-007 <s.raide@gmail.com>
This commit was merged in pull request #16.
This commit is contained in:
2026-08-29 18:25:30 +00:00
committed by codegirl007
parent 1acc296541
commit a6232ea784
6 changed files with 298 additions and 68 deletions
+3 -3
View File
@@ -37,6 +37,7 @@ func main() {
log.Fatalf("mail: %v", err)
}
bus := events.New()
mail.Subscribe(bus, store.NewPostgres(db), notifier)
bot, err := discord.FromEnv(store.NewDiscordLinks(db), bus, store.NewPostgres(db), notifier)
if err != nil {
log.Fatalf("discord: %v", err)
@@ -44,7 +45,7 @@ func main() {
if bot != nil {
defer bot.Close()
}
handler := newHandler(db, sessions, uploader, notifier, bus)
handler := newHandler(db, sessions, uploader, bus)
run(&http.Server{
Addr: listenAddr(),
Handler: handler,
@@ -68,13 +69,12 @@ func openDB() (*sql.DB, *store.SessionStore) {
return db, sessions
}
func newHandler(db *sql.DB, sessions *store.SessionStore, uploader blob.Uploader, notifier mail.Notifier, bus events.Publisher) http.Handler {
func newHandler(db *sql.DB, sessions *store.SessionStore, uploader blob.Uploader, bus events.Publisher) http.Handler {
srv, err := web.New(store.NewPostgres(db), sessions.Store(), plumber.TemplateFS, plumber.StaticFS, web.Config{
AdminSetupSecret: strings.TrimSpace(os.Getenv("ADMIN_SETUP_SECRET")),
SecureCookie: secureCookieFromEnv(),
TrustedProxies: parseTrustedProxies(os.Getenv("TRUSTED_PROXY_CIDRS")),
Blob: uploader,
Mail: notifier,
Events: bus,
BaseURL: strings.TrimRight(strings.TrimSpace(os.Getenv("APP_BASE_URL")), "/"),
})