Tweak email formatting for chat room reports

This commit is contained in:
Noah Petherbridge 2023-08-12 21:47:33 -07:00
parent 8ac63bf800
commit d37ab56f26

View File

@ -67,6 +67,9 @@ func Report() http.HandlerFunc {
// Get the report out. // Get the report out.
report := req.Report report := req.Report
if report.Comment == "" {
report.Comment = "(no comment)"
}
log.Debug("Got chat report: %+v", report) log.Debug("Got chat report: %+v", report)
@ -95,8 +98,11 @@ func Report() http.HandlerFunc {
} }
// Get the Reply-To user if possible. // Get the Reply-To user if possible.
if user, err := models.FindUser(report.FromUsername); err == nil { currentUser, err := models.FindUser(report.FromUsername)
fb.UserID = user.ID if err == nil {
fb.UserID = currentUser.ID
} else {
currentUser = nil
} }
// Save the feedback. // Save the feedback.
@ -107,15 +113,16 @@ func Report() http.HandlerFunc {
// Email the admins. // Email the admins.
if err := mail.Send(mail.Message{ if err := mail.Send(mail.Message{
To: config.Current.AdminEmail, To: config.Current.AdminEmail,
Subject: "Chat Room Report", Subject: "User Feedback: Chat Room Report",
Template: "email/contact_admin.html", Template: "email/contact_admin.html",
Data: map[string]interface{}{ Data: map[string]interface{}{
"Title": "Chat Room Report", "Title": "Chat Room Report",
"Intent": fb.Intent, "Intent": fb.Intent,
"Subject": fb.Subject, "Subject": fb.Subject,
"Message": "Please check on the admin dashboard of nonshy.com", "Message": fb.Message,
"BaseURL": config.Current.BaseURL, "CurrentUser": currentUser,
"AdminURL": config.Current.BaseURL + "/admin/feedback", "BaseURL": config.Current.BaseURL,
"AdminURL": config.Current.BaseURL + "/admin/feedback",
}, },
}); err != nil { }); err != nil {
log.Error("/v1/barertc/report page: couldn't send email: %s", err) log.Error("/v1/barertc/report page: couldn't send email: %s", err)