fix: send test email to the user that has requested it

This commit is contained in:
Elias Schneider
2025-01-10 09:25:26 +01:00
parent 82e475a923
commit a649c4b4a5
2 changed files with 5 additions and 3 deletions

View File

@@ -183,7 +183,9 @@ func (acc *AppConfigController) updateImage(c *gin.Context, imageName string, ol
}
func (acc *AppConfigController) testEmailHandler(c *gin.Context) {
err := acc.emailService.SendTestEmail()
userID := c.GetString("userID")
err := acc.emailService.SendTestEmail(userID)
if err != nil {
c.Error(err)
return

View File

@@ -44,9 +44,9 @@ func NewEmailService(appConfigService *AppConfigService, db *gorm.DB) (*EmailSer
}, nil
}
func (srv *EmailService) SendTestEmail() error {
func (srv *EmailService) SendTestEmail(recipientUserId string) error {
var user model.User
if err := srv.db.First(&user).Error; err != nil {
if err := srv.db.First(&user, "id = ?", recipientUserId).Error; err != nil {
return err
}