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
13
api/form.go
13
api/form.go
@ -47,13 +47,24 @@ func theActualFormCode(w http.ResponseWriter, r *http.Request) {
|
|||||||
postData := url.Values{
|
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)},
|
"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)},
|
||||||
}
|
}
|
||||||
|
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)
|
req, err := http.PostForm(webhookURL, postData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Something went terribly wrong!", err)
|
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:
|
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)
|
||||||
}
|
}
|
||||||
|
3
main.go
3
main.go
@ -23,7 +23,7 @@ func main() {
|
|||||||
otherthings.CheckEnv()
|
otherthings.CheckEnv()
|
||||||
log.Println("[HTTP] Starting server")
|
log.Println("[HTTP] Starting server")
|
||||||
port := os.Getenv("SEGFAUTILITIES_PORT")
|
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"))
|
tmpl := template.Must(template.ParseFiles("static/index.html"))
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
data := StaticThingy{
|
data := StaticThingy{
|
||||||
@ -35,7 +35,6 @@ func main() {
|
|||||||
tmpl_form := template.Must(template.ParseFiles("static/form.html"))
|
tmpl_form := template.Must(template.ParseFiles("static/form.html"))
|
||||||
http.HandleFunc("/form/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/form/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
data := StaticThingy{
|
data := StaticThingy{
|
||||||
Port: port,
|
|
||||||
HCaptchaSiteKey: hcaptcha_site_key,
|
HCaptchaSiteKey: hcaptcha_site_key,
|
||||||
}
|
}
|
||||||
tmpl_form.Execute(w, data)
|
tmpl_form.Execute(w, data)
|
||||||
|
@ -50,6 +50,12 @@
|
|||||||
required
|
required
|
||||||
placeholder="Your message"
|
placeholder="Your message"
|
||||||
></textarea>
|
></textarea>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="webhook"
|
||||||
|
placeholder="Your webhook URL"
|
||||||
|
required
|
||||||
|
/>
|
||||||
<div class="h-captcha" data-sitekey="{{.HCaptchaSiteKey}}"></div>
|
<div class="h-captcha" data-sitekey="{{.HCaptchaSiteKey}}"></div>
|
||||||
<input type="submit" value="Submit" />
|
<input type="submit" value="Submit" />
|
||||||
</form>
|
</form>
|
||||||
|
Reference in New Issue
Block a user