From d37ab56f268df69bbbb74345aacc8701cce6d41d Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sat, 12 Aug 2023 21:47:33 -0700 Subject: [PATCH] Tweak email formatting for chat room reports --- .../api/barertc/barertc_webhooks.go | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/pkg/controller/api/barertc/barertc_webhooks.go b/pkg/controller/api/barertc/barertc_webhooks.go index e4e45e8..71cdad7 100644 --- a/pkg/controller/api/barertc/barertc_webhooks.go +++ b/pkg/controller/api/barertc/barertc_webhooks.go @@ -67,6 +67,9 @@ func Report() http.HandlerFunc { // Get the report out. report := req.Report + if report.Comment == "" { + report.Comment = "(no comment)" + } log.Debug("Got chat report: %+v", report) @@ -95,8 +98,11 @@ func Report() http.HandlerFunc { } // Get the Reply-To user if possible. - if user, err := models.FindUser(report.FromUsername); err == nil { - fb.UserID = user.ID + currentUser, err := models.FindUser(report.FromUsername) + if err == nil { + fb.UserID = currentUser.ID + } else { + currentUser = nil } // Save the feedback. @@ -107,15 +113,16 @@ func Report() http.HandlerFunc { // Email the admins. if err := mail.Send(mail.Message{ To: config.Current.AdminEmail, - Subject: "Chat Room Report", + Subject: "User Feedback: Chat Room Report", Template: "email/contact_admin.html", Data: map[string]interface{}{ - "Title": "Chat Room Report", - "Intent": fb.Intent, - "Subject": fb.Subject, - "Message": "Please check on the admin dashboard of nonshy.com", - "BaseURL": config.Current.BaseURL, - "AdminURL": config.Current.BaseURL + "/admin/feedback", + "Title": "Chat Room Report", + "Intent": fb.Intent, + "Subject": fb.Subject, + "Message": fb.Message, + "CurrentUser": currentUser, + "BaseURL": config.Current.BaseURL, + "AdminURL": config.Current.BaseURL + "/admin/feedback", }, }); err != nil { log.Error("/v1/barertc/report page: couldn't send email: %s", err)