This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
|
||||
"plumber/internal/blob"
|
||||
"plumber/internal/events"
|
||||
"plumber/internal/geo"
|
||||
"plumber/internal/mail"
|
||||
"plumber/internal/pacific"
|
||||
@@ -35,6 +36,8 @@ type Config struct {
|
||||
TrustedProxies []*net.IPNet
|
||||
Blob blob.Uploader
|
||||
Mail mail.Notifier
|
||||
Events events.Publisher
|
||||
BaseURL string
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
@@ -110,6 +113,9 @@ func New(st store.Store, sessionStore scs.Store, templateFS fs.FS, staticFS fs.F
|
||||
if cfg.Mail == nil {
|
||||
cfg.Mail = mail.Nop{}
|
||||
}
|
||||
if cfg.Events == nil {
|
||||
cfg.Events = events.Nop{}
|
||||
}
|
||||
funcMap := template.FuncMap{
|
||||
"voteCtx": func(user *store.User, csrf, view, date string, post *store.Post) voteCtx {
|
||||
return voteCtx{User: user, CSRF: csrf, View: view, Date: date, Post: post}
|
||||
@@ -371,6 +377,7 @@ func (s *Server) handleSubmit(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "could not save question", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
s.publishPostCreated(post, post, u)
|
||||
http.Redirect(w, r, "/questions/"+url.PathEscape(post.ID), http.StatusSeeOther)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user