From 4cbc21044c96d903564963b794a40a5381d63e86 Mon Sep 17 00:00:00 2001 From: odinkh <odinkh@stud.ntnu.no> Date: Thu, 19 May 2022 20:19:57 +0200 Subject: [PATCH] Commenting and removal of prints. --- api/EscalateAnalysis.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/api/EscalateAnalysis.go b/api/EscalateAnalysis.go index c7261d0..c4865a1 100644 --- a/api/EscalateAnalysis.go +++ b/api/EscalateAnalysis.go @@ -13,11 +13,12 @@ import ( //Function linked to the escalation to manual analysis button in the frontend. Function sends email to user whom requested manual analysis. //Function utlizes the gomail package. +//This function has been created with inspiration from https://www.loginradius.com/blog/engineering/sending-emails-with-golang/. func EscalateAnalysis(url string, result string, token string, hash string) { - email_pwd := os.Getenv("email_pwd") + email_pwd := os.Getenv("email_pwd") //Get service password from ENV. - from := "threattotalv2@gmail.com" + from := "threattotalv2@gmail.com" //Address to send email from. to := getUserEmail(token) //Gets the email of the user. @@ -52,6 +53,7 @@ func EscalateAnalysis(url string, result string, token string, hash string) { // Now send E-Mail if err := d.DialAndSend(m); err != nil { fmt.Println(err) + logging.Logerror(err, "Error sending email - EscalateManualAnalysis.") } } @@ -68,17 +70,18 @@ func getUserEmail(hash string) (email string) { } } - responseBytes, err := json.Marshal(value) //Marshal data + responseBytes, err := json.Marshal(value) //Marshal data if err != nil { fmt.Println(err) + logging.Logerror(err, "Error marshalling data") } var test []byte var JWTdata utils.IdAndJwt - err = json.Unmarshal(responseBytes, &test) //Unmarshal data + err = json.Unmarshal(responseBytes, &test) //Unmarshal data json.Unmarshal(test, &JWTdata) - email = fmt.Sprintf("%s", JWTdata.Claims["email"]) //Set the email - return email //Return the email. + email = fmt.Sprintf("%s", JWTdata.Claims["email"]) //Set the email + return email //Return the email. } -- GitLab