aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorFChannel <=>2021-01-30 01:59:06 -0800
committerFChannel <=>2021-01-30 01:59:06 -0800
commit99fcc761a0fe1141a997d4d8709dd2bca18efcdb (patch)
tree33d5bff8f74faba270b23f0aa9d1f5ca942c266b /client.go
parentf0afe325423011a8cb4eed5192375fcae5312da3 (diff)
removed get captcha url
Diffstat (limited to 'client.go')
-rw-r--r--client.go28
1 files changed, 4 insertions, 24 deletions
diff --git a/client.go b/client.go
index 9c9ce9c..cede640 100644
--- a/client.go
+++ b/client.go
@@ -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+$")