Merge branch 'odyssey-fixes' of https://github.com/ProjectSegfault/Segfautils into odyssey-fixes

This commit is contained in:
Odyssey 2022-10-18 15:29:39 +02:00
commit c8ef8262c3

View File

@ -2,8 +2,10 @@ package api
import ( import (
"fmt" "fmt"
"io"
"log" "log"
"net/http" "net/http"
"net/url"
"text/template" "text/template"
"github.com/ProjectSegfault/segfautils/config" "github.com/ProjectSegfault/segfautils/config"
@ -73,10 +75,18 @@ func theActualFormCode(w http.ResponseWriter, r *http.Request) {
} }
} else { } else {
fmt.Fprintf(w, "Thanks for your message, and thanks for doing the captcha!\nPlease ignore how different this page looks to the page you were on earlier. I'll figure it out eventually!\n%#+v", hcaptchaResp) fmt.Fprintf(w, "Thanks for your message, and thanks for doing the captcha!\nPlease ignore how different this page looks to the page you were on earlier. I'll figure it out eventually!\n%#+v", hcaptchaResp)
postData := url.Values{
"content": {"IP " + utils.GetUserIP(r) + "\nFrom " + r.FormValue("email") + " with feedback type " + r.FormValue("commentType") + ":\n" + "**" + r.FormValue("message") + "**\n https://abuseipdb.com/check/" + utils.GetUserIP(r)},
}
shoutrrr := shoutrrr.Send(config.ShoutrrrURL(), "IP "+utils.GetUserIP(r)+"\nFrom "+r.FormValue("email")+" with feedback type "+r.FormValue("commentType")+":\n"+"**"+r.FormValue("message")+"**\n https://abuseipdb.com/check/"+utils.GetUserIP(r)) shoutrrr := shoutrrr.Send(config.ShoutrrrURL(), "IP "+utils.GetUserIP(r)+"\nFrom "+r.FormValue("email")+" with feedback type "+r.FormValue("commentType")+":\n"+"**"+r.FormValue("message")+"**\n https://abuseipdb.com/check/"+utils.GetUserIP(r))
if shoutrrr != nil { if shoutrrr != nil {
log.Println("[Segfautils] ✖ Failed to send webhook") log.Fatal("Something went terribly wrong!", shoutrrr)
} }
req, err := http.PostForm(webhookURL, postData)
if err != nil {
log.Fatal("Something went terribly wrong!", err)
}
fmt.Fprint(io.Discard, req) // Out with your request! I don't want it.
} }
default: default:
http.Error(w, "Method isn't allowed!\nYou may only POST here, not "+r.Method, http.StatusMethodNotAllowed) http.Error(w, "Method isn't allowed!\nYou may only POST here, not "+r.Method, http.StatusMethodNotAllowed)