added crawling for web reciever

fixed crawling settings condition
This commit is contained in:
farhan 2020-12-29 20:06:18 +00:00
parent 20fb4ed76a
commit b2974b7501
3 changed files with 22 additions and 3 deletions

View File

@ -186,7 +186,7 @@ func PollMastodonPleroma(endpoint string, o *RunningInstance) {
} }
// Only done if we are crawling // 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 // Skip over this if its the same as the endpoint
if newinstance == endpoint { if newinstance == endpoint {
continue continue

View File

@ -98,7 +98,7 @@ func StreamMastodon(endpoint string, o *RunningInstance) {
at_sign := strings.Index(newpost.Account.Acct, "@") at_sign := strings.Index(newpost.Account.Acct, "@")
newinstance := newpost.Account.Acct[at_sign+1:] 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() ri_mutex.Lock()
o, exists := runninginstances[newinstance] o, exists := runninginstances[newinstance]
if exists == false || o.Status == KEEPALIVE { if exists == false || o.Status == KEEPALIVE {

21
web.go
View File

@ -9,7 +9,7 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
// "strings" "strings"
// "time" // "time"
) )
@ -118,6 +118,25 @@ func inboxHandler() http.HandlerFunc {
} }
go check_post(createobject.ID) 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 "Like":
case "Announcement": case "Announcement":
case "Delete": case "Delete":