diff options
author | FChannel <=> | 2021-01-24 10:59:49 -0800 |
---|---|---|
committer | FChannel <=> | 2021-01-24 10:59:49 -0800 |
commit | 895d90f8dd038540e65cf291f003195a0f6bd024 (patch) | |
tree | f8c9dcd4fc735cc1b9dc76866df8215c516abb8f | |
parent | 2ca021e2c6599b39e6225fdbd449093517a34418 (diff) |
domain routing bug
-rw-r--r-- | Database.go | 22 | ||||
-rw-r--r-- | Follow.go | 1 | ||||
-rw-r--r-- | OutboxPost.go | 1 | ||||
-rw-r--r-- | client.go | 7 | ||||
-rw-r--r-- | clientkey | 2 | ||||
-rw-r--r-- | main.go | 15 | ||||
-rw-r--r-- | session.go | 6 |
7 files changed, 47 insertions, 7 deletions
diff --git a/Database.go b/Database.go index 275bfcd..ea1b031 100644 --- a/Database.go +++ b/Database.go @@ -30,6 +30,28 @@ func GetActorFromDB(db *sql.DB, id string) Actor { return nActor } +func GetActorByNameFromDB(db *sql.DB, name string) Actor { + var nActor Actor + + query :=`select type, id, name, preferedusername, inbox, outbox, following, followers, restricted, summary from actor where name=$1` + + rows, err := db.Query(query, name) + + if CheckError(err, "could not get actor from db query") != nil { + return nActor + } + + defer rows.Close() + for rows.Next() { + err = rows.Scan(&nActor.Type, &nActor.Id, &nActor.Name, &nActor.PreferredUsername, &nActor.Inbox, &nActor.Outbox, &nActor.Following, &nActor.Followers, &nActor.Restricted, &nActor.Summary) + CheckError(err, "error with actor from db scan ") + } + + nActor.AtContext.Context = "https://www.w3.org/ns/activitystreams" + + return nActor +} + func CreateNewBoardDB(db *sql.DB, actor Actor) Actor{ query := `insert into actor (type, id, name, preferedusername, inbox, outbox, following, followers, summary) values ($1, $2, $3, $4, $5, $6, $7, $8, $9)` @@ -190,7 +190,6 @@ func SetActorFollowingDB(db *sql.DB, activity Activity) Activity { alreadyFollow := false following := GetActorFollowingDB(db, activity.Object.Actor.Id) - for _, e := range following { if e.Id == activity.Actor.Id { alreadyFollow = true diff --git a/OutboxPost.go b/OutboxPost.go index f66c234..dbb49d2 100644 --- a/OutboxPost.go +++ b/OutboxPost.go @@ -110,6 +110,7 @@ func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) { SetActorFollowingDB(db, rActivity) MakeActivityRequest(activity) } + w.Write([]byte("")) case "Delete": fmt.Println("This is a delete") @@ -389,6 +389,13 @@ func WantToServe(db *sql.DB, actorName string) (Collection, bool) { var collection Collection serve := false + + boardActor := GetActorByNameFromDB(db, actorName) + + if boardActor.Id != "" { + collection = GetActorCollectionDB(db, boardActor) + return collection, true + } for _, e := range *Boards { boardActor := GetActorFromDB(db, e.Id) @@ -1 +1 @@ -fcc28cdb95d2983a10efdc8f3b8a9503
\ No newline at end of file +515ff978b24a657d3d1076da3cfe5102
\ No newline at end of file @@ -100,9 +100,9 @@ func main() { var method = r.Method - var actor = GetActorFromPath(db, path, "/") + var actor = GetActorFromPath(db, path, "/") - if actor.Name == "" { + if actor.Name == "main" { mainActor = (path == "/") mainInbox = (path == "/inbox") mainOutbox = (path == "/outbox") @@ -429,7 +429,10 @@ func main() { CheckError(err, "error with add board follow resp") + + following := GetActorFollowingDB(db, Domain) + Boards = &following http.Redirect(w, r, r.Header.Get("Referer"), http.StatusSeeOther) @@ -916,8 +919,12 @@ func GetActorFromPath(db *sql.DB, location string, prefix string) Actor { } var nActor Actor - - nActor = GetActorByName(db, actor) + + nActor = GetActorByNameFromDB(db, actor) + + if nActor.Id == "" { + nActor = GetActorByName(db, actor) + } return nActor } @@ -86,5 +86,9 @@ func GetPasswordFromSession(r *http.Request) (string, string) { parts := strings.Split(token, "|") - return parts[0], parts[1] + if len(parts) > 1 { + return parts[0], parts[1] + } + + return "", "" } |