aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorFChannel <>2021-07-30 16:28:55 -0700
committerFChannel <>2021-07-30 16:28:55 -0700
commita1ecad89f575b7d8542eea75979b4c11bfa199d4 (patch)
tree6e06ae5cbd75cc527167a4033e5faa48b0f7939f /main.go
parent7c6ee8f4073a5b8fd9cc065f225c9f09f21ee4a1 (diff)
added removal of inactive instances from following/followers after 24hrs
Diffstat (limited to 'main.go')
-rw-r--r--main.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/main.go b/main.go
index c851663..5da910a 100644
--- a/main.go
+++ b/main.go
@@ -1769,6 +1769,7 @@ func ParseCommentForReplies(db *sql.DB, comment string, op string) []ObjectBase
}
func CheckValidActivity(id string) (Collection, bool) {
+ var respCollection Collection
re := regexp.MustCompile(`.+\.onion(.+)?`)
if re.MatchString(id) {
@@ -1779,7 +1780,6 @@ func CheckValidActivity(id string) (Collection, bool) {
if err != nil {
fmt.Println("error with request")
- panic(err)
}
req.Header.Set("Accept", activitystreams)
@@ -1788,15 +1788,13 @@ func CheckValidActivity(id string) (Collection, bool) {
if err != nil {
fmt.Println("error with response")
- panic(err)
+ return respCollection, false
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
- var respCollection Collection
-
err = json.Unmarshal(body, &respCollection)
if err != nil {
@@ -2181,7 +2179,10 @@ func MakeActivityRequest(db *sql.DB, activity Activity) {
_, err = RouteProxy(req)
if err != nil {
- fmt.Println("error with sending activity resp to actor " + instance)
+ fmt.Println("error with sending activity resp to actor " + instance + " instance marked as inactive and will be removed from following and followers in 24 hrs")
+ AddInstanceToInactiveDB(db, instance)
+ } else {
+ DeleteInstanceFromInactiveDB(db, instance)
}
}
}
@@ -2555,7 +2556,7 @@ func RouteProxy(req *http.Request) (*http.Response, error) {
CheckError(err, "error parsing tor proxy url")
proxyTransport := &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
- client := &http.Client{ Transport: proxyTransport, Timeout: time.Second * 75 }
+ client := &http.Client{ Transport: proxyTransport, Timeout: time.Second * 30 }
return client.Do(req)
}
@@ -2801,10 +2802,6 @@ func RouteImages(w http.ResponseWriter, media string) {
resp, err := http.DefaultClient.Do(req)
- if err != nil {
- fmt.Println("error with Route Images resp " + MediaHashs[media])
- }
-
if err != nil || resp.StatusCode == 404 {
fileBytes, err := ioutil.ReadFile("./static/notfound.png")