aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go45
-rw-r--r--outboxPost.go6
2 files changed, 15 insertions, 36 deletions
diff --git a/main.go b/main.go
index 5d0e782..eb3c4f0 100644
--- a/main.go
+++ b/main.go
@@ -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 {
diff --git a/outboxPost.go b/outboxPost.go
index edbea65..2a06211 100644
--- a/outboxPost.go
+++ b/outboxPost.go
@@ -92,8 +92,8 @@ func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) {
w.Write([]byte(""))
return
}
-
- _, validActor = IsValidActor(activity.Object.Actor.Id)
+
+ validActor = (FingerActor(activity.Object.Actor.Id).Id != "")
validLocalActor = (activity.Actor.Id == actor.Id)
var verify Verify
@@ -117,7 +117,7 @@ func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) {
}
var rActivity Activity
- if validActor && validLocalActor && code == auth[1] || verify.Board == Domain {
+ if validActor && validLocalActor && code == auth[1] {
rActivity = AcceptFollow(activity)
SetActorFollowingDB(db, rActivity)
MakeActivityRequest(db, activity)