use your own webhook you leech and fix akisbug
Signed-off-by: Odyssey346 <odyssey346@disroot.org>
This commit is contained in:
parent
c19bf73077
commit
140be4e9dd
21
api/form.go
21
api/form.go
@ -47,12 +47,23 @@ func theActualFormCode(w http.ResponseWriter, r *http.Request) {
|
||||
postData := url.Values{
|
||||
"content": {"IP " + otherthings.GetUserIP(r) + "\nFrom " + r.FormValue("email") + " with feedback type " + r.FormValue("commentType") + ":\n" + "**" + r.FormValue("message") + "**\n https://abuseipdb.com/check/" + otherthings.GetUserIP(r)},
|
||||
}
|
||||
req, err := http.PostForm(webhookURL, postData)
|
||||
if err != nil {
|
||||
log.Fatal("Something went terribly wrong!", err)
|
||||
if r.FormValue("webhook") != "" {
|
||||
fmt.Fprintf(w, "\nThanks for trying Segfautilities Contact Form :)")
|
||||
postData := url.Values{
|
||||
"content": {"**Note: you are currently testing our form example. Please check out the actual project at https://github.com/ProjectSegfault/segfautilities! It's not hard to self-host :)**\n" + "IP " + otherthings.GetUserIP(r) + "\nFrom " + r.FormValue("email") + " with feedback type " + r.FormValue("commentType") + ":\n" + "**" + r.FormValue("message") + "**\n https://abuseipdb.com/check/" + otherthings.GetUserIP(r)},
|
||||
}
|
||||
req, err := http.PostForm(r.FormValue("webhook"), postData)
|
||||
if err != nil {
|
||||
log.Println("Someone tried to send a webhook, but it failed!")
|
||||
}
|
||||
fmt.Fprint(io.Discard, req) // I don't want the result of the demo request in stdout at ALL.
|
||||
} else {
|
||||
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.
|
||||
}
|
||||
|
||||
fmt.Fprint(io.Discard, req) // Out with your request! I don't want it.
|
||||
}
|
||||
default:
|
||||
http.Error(w, "Method isn't allowed!\nYou may only POST here, not " + r.Method, http.StatusMethodNotAllowed)
|
||||
|
3
main.go
3
main.go
@ -23,7 +23,7 @@ func main() {
|
||||
otherthings.CheckEnv()
|
||||
log.Println("[HTTP] Starting server")
|
||||
port := os.Getenv("SEGFAUTILITIES_PORT")
|
||||
hcaptcha_site_key := os.Getenv("SEGFAUTILITIES_PORT")
|
||||
hcaptcha_site_key := os.Getenv("HCAPTCHA_SITE_KEY")
|
||||
tmpl := template.Must(template.ParseFiles("static/index.html"))
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
data := StaticThingy{
|
||||
@ -35,7 +35,6 @@ func main() {
|
||||
tmpl_form := template.Must(template.ParseFiles("static/form.html"))
|
||||
http.HandleFunc("/form/", func(w http.ResponseWriter, r *http.Request) {
|
||||
data := StaticThingy{
|
||||
Port: port,
|
||||
HCaptchaSiteKey: hcaptcha_site_key,
|
||||
}
|
||||
tmpl_form.Execute(w, data)
|
||||
|
@ -50,6 +50,12 @@
|
||||
required
|
||||
placeholder="Your message"
|
||||
></textarea>
|
||||
<input
|
||||
type="text"
|
||||
name="webhook"
|
||||
placeholder="Your webhook URL"
|
||||
required
|
||||
/>
|
||||
<div class="h-captcha" data-sitekey="{{.HCaptchaSiteKey}}"></div>
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
|
Reference in New Issue
Block a user