added html admin notification mail

This commit is contained in:
$(pass /github/name)
2024-07-11 12:48:26 +02:00
parent de88a603d5
commit e4475e2400
3 changed files with 44 additions and 6 deletions

View File

@@ -19,6 +19,8 @@ type User struct {
LastName string `gorm:"not null" json:"last_name"`
ProfilePicture string `json:"profile_picture"`
Address string `gorm:"not null" json:"address"`
ZipCode string `gorm:"not null" json:"zip_code"`
City string `form:"not null" json:"city"`
Consents []Consent `gorm:"constraint:OnUpdate:CASCADE"`
BankAccount BankAccount `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
Verification Verification `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`

View File

@@ -102,7 +102,42 @@ func (s *EmailService) SendWelcomeEmail(user *models.User, membership *models.Me
}
func (s *EmailService) NotifyAdminOfNewUser(user *models.User) error {
subject := "New User Registration"
body := "<p>A new user has registered with the email: " + user.Email + "</p>"
return s.SendEmail(s.adminEmail, subject, body)
// Prepare data to be injected into the template
data := struct {
FirstName string
LastName string
MembershipModel string
MembershipID int64
MembershipFee float32
RentalFee float32
Address string
ZipCode string
City string
DateOfBirth string
Email string
Phone string
IBAN string
}{
FirstName: user.FirstName,
LastName: user.LastName,
MembershipModel: user.Membership.SubscriptionModel.Name,
MembershipID: user.Membership.ID,
MembershipFee: float32(user.Membership.SubscriptionModel.MonthlyFee),
RentalFee: float32(user.Membership.SubscriptionModel.HourlyRate),
Address: user.Address,
ZipCode: user.ZipCode,
City: user.City,
DateOfBirth: user.DateOfBirth.Format("20060102"),
Email: user.Email,
Phone: *user.Phone,
IBAN: user.BankAccount.IBAN,
}
subject := "Neues Mitglied hat sich registriert"
body, err := ParseTemplate("mail_registration.html", data)
if err != nil {
logger.Error.Print("Couldn't send admin notification mail")
return err
}
return s.SendEmail(user.Email, subject, body)
}