diff options
author | FChannel <> | 2021-06-06 03:01:19 -0700 |
---|---|---|
committer | FChannel <> | 2021-06-06 03:01:19 -0700 |
commit | 3a4aacb9c49b7d2730b7ec46205a43c5095456d6 (patch) | |
tree | 90bbd5b66402131d7082334bcc6271c6360f27fb /main.go | |
parent | 8f5289cf17c66c10285e5b30904523d51fd23de9 (diff) |
better handling of follow when instance is offline
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 45 |
1 files changed, 12 insertions, 33 deletions
@@ -452,7 +452,7 @@ func main() { } enc, _ := json.Marshal(followActivity) - + req, err := http.NewRequest("POST", actor.Outbox, bytes.NewBuffer(enc)) CheckError(err, "error with follow req") @@ -466,13 +466,14 @@ func main() { req.Header.Set("Content-Type", activitystreams) - _, err = http.DefaultClient.Do(req) - - CheckError(err, "error with add board follow resp") - - FollowingBoards = GetActorFollowingDB(db, Domain) + resp, err := http.DefaultClient.Do(req) - Boards = GetBoardCollection(db) + if err != nil && resp.StatusCode != 200 { + fmt.Println("error with add board follow resp") + } else { + FollowingBoards = GetActorFollowingDB(db, Domain) + Boards = GetBoardCollection(db) + } var redirect string if(actor.Name != "main") { @@ -1550,36 +1551,14 @@ func GetActorCollection(collection string) Collection { } func IsValidActor(id string) (Actor, bool) { - var respCollection Actor - req, err := http.NewRequest("GET", id, nil) - - CheckError(err, "error with valid actor request") - - req.Header.Set("Accept", activitystreams) - - resp, err := http.DefaultClient.Do(req) - CheckError(err, "error with valid actor response") + actor := FingerActor(id) - defer resp.Body.Close() - - if resp.StatusCode == 403 { - return respCollection, false; - } - - body, _ := ioutil.ReadAll(resp.Body) - - err = json.Unmarshal(body, &respCollection) - - if err != nil { - panic(err) - } - - if respCollection.Id != "" && respCollection.Inbox != "" && respCollection.Outbox != "" { - return respCollection, true; + if actor.Id != "" { + return actor, true; } - return respCollection, false; + return actor, false; } func IsActivityLocal(db *sql.DB, activity Activity) bool { |