chore: send admin email on adding waitlist entry
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user