aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFChannel <=>2021-01-28 16:02:03 -0800
committerFChannel <=>2021-01-28 16:02:03 -0800
commitc052a31eacc50ce61dced6f42fec66040329b55f (patch)
tree138ed0c397d0f265444ab8f493f39d443538588c
parent04d5d59acbf340382ecb63c0f98dd55e32e11035 (diff)
cleaned up inbox auth req
-rw-r--r--OutboxPost.go32
1 files changed, 19 insertions, 13 deletions
diff --git a/OutboxPost.go b/OutboxPost.go
index fc4a84a..c2bf7fe 100644
--- a/OutboxPost.go
+++ b/OutboxPost.go
@@ -505,17 +505,25 @@ func ParseInboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) {
activity := GetActivityFromJson(r, db)
header := r.Header.Get("Authorization")
- auth := strings.Split(header, " ")
+ auth := strings.Split(header, " ")
+
+ if len(auth) < 2 {
+ return
+ }
+
+ if !RemoteActorHasAuth(activity.Actor.Id, auth[1]) {
+ return
+ }
+
switch(activity.Type) {
case "Create":
for _, e := range activity.To {
if IsActorLocal(db, e) {
- if !IsActorLocal(db, activity.Actor.Id) && len(auth) > 1 && RemoteActorHasAuth(activity.Actor.Id, auth[1]){
+ if !IsActorLocal(db, activity.Actor.Id) {
WriteObjectToCache(db, *activity.Object)
}
}
}
-
break
case "Delete":
@@ -531,16 +539,14 @@ func ParseInboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) {
case "Follow":
for _, e := range activity.To {
- if len(auth) > 1 && RemoteActorHasAuth(activity.Actor.Id, auth[1]) {
- if GetActorFromDB(db, e).Id != "" {
- response := AcceptFollow(activity)
- response = SetActorFollowerDB(db, response)
- MakeActivityRequest(db, response)
- } else {
- fmt.Println("follow request for rejected")
- response := RejectFollow(activity)
- MakeActivityRequest(db, response)
- }
+ if GetActorFromDB(db, e).Id != "" {
+ response := AcceptFollow(activity)
+ response = SetActorFollowerDB(db, response)
+ MakeActivityRequest(db, response)
+ } else {
+ fmt.Println("follow request for rejected")
+ response := RejectFollow(activity)
+ MakeActivityRequest(db, response)
}
}
break