feat(webhook): add webhook client for RSVP and photo uploads

This commit is contained in:
2026-08-12 20:27:42 +02:00
parent df5d8efeb1
commit d8f70cf731
5 changed files with 136 additions and 6 deletions
+13 -5
View File
@@ -17,16 +17,18 @@ import (
"wedding-server/internal/config"
"wedding-server/internal/mail"
"wedding-server/internal/store"
"wedding-server/internal/webhook"
)
type Server struct {
cfg *config.Config
store *store.Store
mailer *mail.Mailer
cfg *config.Config
store *store.Store
mailer *mail.Mailer
webhook *webhook.Client
}
func New(cfg *config.Config, st *store.Store, mailer *mail.Mailer) *Server {
return &Server{cfg: cfg, store: st, mailer: mailer}
func New(cfg *config.Config, st *store.Store, mailer *mail.Mailer, wh *webhook.Client) *Server {
return &Server{cfg: cfg, store: st, mailer: mailer, webhook: wh}
}
func (s *Server) Routes(mux *http.ServeMux) {
@@ -105,6 +107,9 @@ func (s *Server) handleRSVP(w http.ResponseWriter, r *http.Request) {
if err := s.mailer.SendRSVP(rsvp); err != nil {
log.Printf("rsvp: email failed: %v", err)
}
if err := s.webhook.SendRSVP(rsvp); err != nil {
log.Printf("rsvp: webhook failed: %v", err)
}
writeJSON(w, http.StatusCreated, map[string]bool{"ok": true})
}
@@ -275,6 +280,9 @@ func (s *Server) handlePhotoUpload(w http.ResponseWriter, r *http.Request) {
if err := s.mailer.SendPhotoUpload(upload, saved); err != nil {
log.Printf("photos: email failed: %v", err)
}
if err := s.webhook.SendPhotoUpload(upload, saved); err != nil {
log.Printf("photos: webhook failed: %v", err)
}
writeJSON(w, http.StatusCreated, map[string]bool{"ok": true})
}