From b2974b7501d17600bc07024387dfc832aeedfac6 Mon Sep 17 00:00:00 2001 From: Farhan Khan Date: Tue, 29 Dec 2020 20:06:18 +0000 Subject: [PATCH] added crawling for web reciever fixed crawling settings condition --- poll.go | 2 +- stream.go | 2 +- web.go | 21 ++++++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/poll.go b/poll.go index b445947..ef3250a 100644 --- a/poll.go +++ b/poll.go @@ -186,7 +186,7 @@ func PollMastodonPleroma(endpoint string, o *RunningInstance) { } // Only done if we are crawling - if settings.Crawl == true && stringexists(endpoint, settings.Banned) == false { + if settings.Crawl == true && stringexists(newinstance, settings.Banned) == false { // Skip over this if its the same as the endpoint if newinstance == endpoint { continue diff --git a/stream.go b/stream.go index 1228c36..5d8d54f 100644 --- a/stream.go +++ b/stream.go @@ -98,7 +98,7 @@ func StreamMastodon(endpoint string, o *RunningInstance) { at_sign := strings.Index(newpost.Account.Acct, "@") newinstance := newpost.Account.Acct[at_sign+1:] - if settings.Crawl == true && stringexists(endpoint, settings.Banned) == false { + if settings.Crawl == true && stringexists(newinstance, settings.Banned) == false { ri_mutex.Lock() o, exists := runninginstances[newinstance] if exists == false || o.Status == KEEPALIVE { diff --git a/web.go b/web.go index 5032ee7..841943d 100644 --- a/web.go +++ b/web.go @@ -9,7 +9,7 @@ import ( "log" "net/http" "os" -// "strings" + "strings" // "time" ) @@ -118,6 +118,25 @@ func inboxHandler() http.HandlerFunc { } go check_post(createobject.ID) + slashend := strings.Index(createobject.ID[8:], "/") + newinstance := createobject.ID[8:8+slashend] + log.Print("The at sign is: ", newinstance) + + // Only done if we are crawling + if settings.Crawl == true && stringexists(newinstance, settings.Banned) == false { + // Skip over this if its the same as the endpoint + ri_mutex.Lock() + o, exists := runninginstances[newinstance] + if exists == false || o.Status == KEEPALIVE { + m := RunningInstance{} + runninginstances[newinstance] = m + go StartInstance(newinstance) + } + + ri_mutex.Unlock() + + } + case "Like": case "Announcement": case "Delete":