diff options
author | FChannel <=> | 2021-01-30 01:59:06 -0800 |
---|---|---|
committer | FChannel <=> | 2021-01-30 01:59:06 -0800 |
commit | 99fcc761a0fe1141a997d4d8709dd2bca18efcdb (patch) | |
tree | 33d5bff8f74faba270b23f0aa9d1f5ca942c266b | |
parent | f0afe325423011a8cb4eed5192375fcae5312da3 (diff) |
removed get captcha url
-rw-r--r-- | client.go | 28 | ||||
-rw-r--r-- | main.go | 4 |
2 files changed, 4 insertions, 28 deletions
@@ -122,7 +122,7 @@ func OutboxGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection Co returnData.Board.Restricted = actor.Restricted returnData.CurrentPage = page - returnData.Board.Captcha = GetCaptcha(*actor) + returnData.Board.Captcha = Domain + "/" + GetRandomCaptcha(db) returnData.Board.CaptchaCode = GetCaptchaCode(returnData.Board.Captcha) returnData.Title = "/" + actor.Name + "/ - " + actor.PreferredUsername @@ -202,7 +202,7 @@ func OutboxGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection Co for i := 0.0; i < pageLimit; i++ { pages = append(pages, int(i)) } - + returnData.Pages = pages returnData.TotalPage = len(returnData.Pages) - 1 @@ -249,7 +249,7 @@ func CatalogGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection C returnData.Board.Restricted = actor.Restricted returnData.Key = *Key - returnData.Board.Captcha = GetCaptcha(*actor) + returnData.Board.Captcha = Domain + "/" + GetRandomCaptcha(db) returnData.Board.CaptchaCode = GetCaptchaCode(returnData.Board.Captcha) returnData.Title = "/" + actor.Name + "/ - " + actor.PreferredUsername @@ -294,7 +294,7 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ if GetDomainURL(actor) != "" { - returnData.Board.Captcha = GetCaptcha(actor) + returnData.Board.Captcha = Domain + "/" + GetRandomCaptcha(db) returnData.Board.CaptchaCode = GetCaptchaCode(returnData.Board.Captcha) } @@ -455,26 +455,6 @@ func StripTransferProtocol(value string) string { return value } -func GetCaptcha(actor Actor) string { - re := regexp.MustCompile("(https://|http://)?(www)?.+/") - - domainURL := re.FindString(actor.Id) - - re = regexp.MustCompile("/$") - - domainURL = re.ReplaceAllString(domainURL, "") - - resp, err := http.Get(domainURL + "/getcaptcha") - - CheckError(err, "error getting captcha") - - defer resp.Body.Close() - - body, _ := ioutil.ReadAll(resp.Body) - - return domainURL + "/" + string(body) -} - func GetCaptchaCode(captcha string) string { re := regexp.MustCompile("\\w+\\.\\w+$") @@ -682,10 +682,6 @@ func main() { } }) - http.HandleFunc("/getcaptcha", func(w http.ResponseWriter, r *http.Request){ - w.Write([]byte(GetRandomCaptcha(db))) - }) - http.HandleFunc("/delete", func(w http.ResponseWriter, r *http.Request){ id := r.URL.Query().Get("id") board := r.URL.Query().Get("board") |