chore: send admin email on adding waitlist entry

This commit is contained in:
talksik
2026-03-29 09:43:21 -07:00
parent be966d78a8
commit 3d71dbaed0
7 changed files with 201 additions and 16 deletions
+22 -3
View File
@@ -3,8 +3,11 @@ package waitlist
import (
"context"
"errors"
"fmt"
"log/slog"
"time"
pbaero "github.com/flowy-live/llink/genproto/aero"
"github.com/flowy-live/llink/internal/utils"
"github.com/jackc/pgx/v5/pgxpool"
)
@@ -41,12 +44,14 @@ type Service interface {
}
type serviceImpl struct {
repo repository
repo repository
aeroSvc pbaero.PrimaryClient
}
func NewService(pool *pgxpool.Pool) Service {
func NewService(pool *pgxpool.Pool, aeroSvc pbaero.PrimaryClient) Service {
return &serviceImpl{
repo: newRepository(pool),
repo: newRepository(pool),
aeroSvc: aeroSvc,
}
}
@@ -68,6 +73,20 @@ func (s *serviceImpl) AddToWaitlist(ctx context.Context, email string, metadata
return err
}
message := fmt.Sprintf("New human added to the llink waitlist: %s", email)
_, err = s.aeroSvc.ShootEmail(context.Background(), &pbaero.ShootEmailRequest{
ToEmails: []string{"[email protected]"},
Subject: "Flowy Llink - New Waitlist Subscriber",
TemplateData: &pbaero.ShootEmailRequest_GenericFlowyAdminAlertData{
GenericFlowyAdminAlertData: &pbaero.GenericFlowyAdminAlertData{
Message: message,
},
},
})
if err != nil {
slog.Error("failed to add to waitlist", "error", err, "email", email)
}
return nil
}