aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFChannel <=>2021-01-24 10:59:49 -0800
committerFChannel <=>2021-01-24 10:59:49 -0800
commit895d90f8dd038540e65cf291f003195a0f6bd024 (patch)
treef8c9dcd4fc735cc1b9dc76866df8215c516abb8f
parent2ca021e2c6599b39e6225fdbd449093517a34418 (diff)
domain routing bug
-rw-r--r--Database.go22
-rw-r--r--Follow.go1
-rw-r--r--OutboxPost.go1
-rw-r--r--client.go7
-rw-r--r--clientkey2
-rw-r--r--main.go15
-rw-r--r--session.go6
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)`
diff --git a/Follow.go b/Follow.go
index 94469c2..8659604 100644
--- a/Follow.go
+++ b/Follow.go
@@ -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")
diff --git a/client.go b/client.go
index e0c5975..b197168 100644
--- a/client.go
+++ b/client.go
@@ -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)
diff --git a/clientkey b/clientkey
index 98282ee..37b5687 100644
--- a/clientkey
+++ b/clientkey
@@ -1 +1 @@
-fcc28cdb95d2983a10efdc8f3b8a9503 \ No newline at end of file
+515ff978b24a657d3d1076da3cfe5102 \ No newline at end of file
diff --git a/main.go b/main.go
index e4d1190..e9cdb2f 100644
--- a/main.go
+++ b/main.go
@@ -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
}
diff --git a/session.go b/session.go
index 3478802..0867b16 100644
--- a/session.go
+++ b/session.go
@@ -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 "", ""
}