aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CacheDatabase.go8
-rw-r--r--Database.go18
-rw-r--r--OutboxPost.go3
-rw-r--r--activityPubStruct.go2
-rw-r--r--go.mod2
-rw-r--r--main.go6
-rw-r--r--outboxGet.go7
7 files changed, 11 insertions, 35 deletions
diff --git a/CacheDatabase.go b/CacheDatabase.go
index 9de9c78..8577c0f 100644
--- a/CacheDatabase.go
+++ b/CacheDatabase.go
@@ -361,7 +361,6 @@ func GetObjectRepliesCache(db *sql.DB, parent ObjectBase) (*CollectionBase, int,
err = rows.Scan(&post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.AttributedTo, &attachID, &previewID, &actor.Id)
-
CheckError(err, "error with replies db scan")
post.Actor = &actor
@@ -384,11 +383,9 @@ func GetObjectRepliesCache(db *sql.DB, parent ObjectBase) (*CollectionBase, int,
nColl.OrderedItems = result
- /*
- remoteCollection := GetObjectRepliesRemote(db, parent)
+
+ remoteCollection, postc, imgc := GetObjectRepliesDB(db, parent)
- var postc int
- var imgc int
for _, e := range remoteCollection.OrderedItems {
nColl.OrderedItems = append(nColl.OrderedItems, e)
postc = postc + 1
@@ -396,7 +393,6 @@ func GetObjectRepliesCache(db *sql.DB, parent ObjectBase) (*CollectionBase, int,
imgc = imgc + 1
}
}
-*/
return &nColl, 0, 0
}
diff --git a/Database.go b/Database.go
index 313ffd8..5a11f22 100644
--- a/Database.go
+++ b/Database.go
@@ -25,8 +25,6 @@ func GetActorFromDB(db *sql.DB, id string) Actor {
CheckError(err, "error with actor from db scan ")
}
- nActor.AtContext.Context = "https://www.w3.org/ns/activitystreams"
-
return nActor
}
@@ -47,8 +45,6 @@ func GetActorByNameFromDB(db *sql.DB, name string) Actor {
CheckError(err, "error with actor from db scan ")
}
- nActor.AtContext.Context = "https://www.w3.org/ns/activitystreams"
-
return nActor
}
@@ -399,13 +395,6 @@ func GetObjectFromDB(db *sql.DB, actor Actor) Collection {
post.Replies.TotalItems, post.Replies.TotalImgs = GetObjectRepliesDBCount(db, post)
- var localPost ObjectBase
- localPost.Replies, postCnt, imgCnt = GetObjectRepliesCache(db, post)
-
- for _, e := range localPost.Replies.OrderedItems {
- post.Replies.OrderedItems = append(post.Replies.OrderedItems, e)
- }
-
post.Replies.TotalItems = post.Replies.TotalItems + postCnt
post.Replies.TotalImgs = post.Replies.TotalImgs + imgCnt
@@ -486,11 +475,9 @@ func GetObjectRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, int, in
nColl.OrderedItems = result
- /*
- remoteCollection := GetObjectRepliesRemote(db, parent)
+
+ remoteCollection, postc, imgc := GetObjectRepliesCache(db, parent)
- var postc int
- var imgc int
for _, e := range remoteCollection.OrderedItems {
nColl.OrderedItems = append(nColl.OrderedItems, e)
postc = postc + 1
@@ -498,7 +485,6 @@ func GetObjectRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, int, in
imgc = imgc + 1
}
}
-*/
return &nColl, 0, 0
}
diff --git a/OutboxPost.go b/OutboxPost.go
index 30c2cc5..898d9e8 100644
--- a/OutboxPost.go
+++ b/OutboxPost.go
@@ -76,7 +76,7 @@ func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) {
if IsActivityLocal(db, activity) {
switch activity.Type {
case "Create":
- if(true) {
+ if(true) { // add condition for creating
object = GetObjectFromActivity(activity)
writeObjectToDB(db, object)
w.WriteHeader(http.StatusCreated)
@@ -456,7 +456,6 @@ func GetActivityFromJson(r *http.Request, db *sql.DB) Activity {
if respActivity.Type == "Note" {
jObj = GetObjectFromJson(body)
- jObj.AtContext.Context = ""
nType = "Create"
} else {
jObj = GetObjectFromJson(respActivity.ObjectRaw)
diff --git a/activityPubStruct.go b/activityPubStruct.go
index f145a01..ff6f237 100644
--- a/activityPubStruct.go
+++ b/activityPubStruct.go
@@ -66,7 +66,6 @@ type CcOjectString struct {
}
type Actor struct {
- AtContext
Type string `json:"type,omitempty"`
Id string `json:"id,omitempty"`
Inbox string `json:"inbox,omitempty"`
@@ -96,7 +95,6 @@ type Activity struct {
}
type ObjectBase struct {
- AtContext
Type string `json:"type,omitempty"`
Id string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
diff --git a/go.mod b/go.mod
index f3d9a97..bf2d6d1 100644
--- a/go.mod
+++ b/go.mod
@@ -1,5 +1,7 @@
module github.com/FChannel/Server
+go 1.15
+
require (
github.com/gofrs/uuid v4.0.0+incompatible
github.com/gomodule/redigo v2.0.0+incompatible
diff --git a/main.go b/main.go
index 76466da..4976fcf 100644
--- a/main.go
+++ b/main.go
@@ -1250,9 +1250,7 @@ func GetActorCollectionCache(db *sql.DB, actor Actor) Collection {
collection.OrderedItems = GetObjectFromCache(db, actor.Id).OrderedItems
- collection.AtContext.Context = "https://www.w3.org/ns/activitystreams"
collection.Actor = &actor
- collection.Actor.AtContext.Context = ""
collection.TotalItems = GetObjectPostsTotalCache(db, actor)
collection.TotalImgs = GetObjectImgsTotalCache(db, actor)
@@ -1265,9 +1263,7 @@ func GetActorCollectionDB(db *sql.DB, actor Actor) Collection {
collection.OrderedItems = GetObjectFromDB(db, actor).OrderedItems
- collection.AtContext.Context = "https://www.w3.org/ns/activitystreams"
collection.Actor = &actor
- collection.Actor.AtContext.Context = ""
collection.TotalItems = GetObjectPostsTotalDB(db, actor)
collection.TotalImgs = GetObjectImgsTotalDB(db, actor)
@@ -1337,7 +1333,7 @@ func IsValidActor(id string) (Actor, bool) {
panic(err)
}
- if respCollection.AtContext.Context == "https://www.w3.org/ns/activitystreams" && respCollection.Id != "" && respCollection.Inbox != "" && respCollection.Outbox != "" {
+ if respCollection.Id != "" && respCollection.Inbox != "" && respCollection.Outbox != "" {
return respCollection, true;
}
diff --git a/outboxGet.go b/outboxGet.go
index 8c178a2..42fafd0 100644
--- a/outboxGet.go
+++ b/outboxGet.go
@@ -10,16 +10,15 @@ func GetActorOutbox(w http.ResponseWriter, r *http.Request, db *sql.DB) {
var collection Collection
collection.OrderedItems = GetObjectFromDB(db, actor).OrderedItems
-
collection.AtContext.Context = "https://www.w3.org/ns/activitystreams"
collection.Actor = &actor
- collection.Actor.AtContext.Context = ""
collection.TotalItems = GetObjectPostsTotalDB(db, actor)
collection.TotalImgs = GetObjectImgsTotalDB(db, actor)
- enc, _ := json.MarshalIndent(collection, "", "\t")
- w.Header().Set("Content-Type", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")
+ enc, _ := json.MarshalIndent(collection, "", "\t")
+
+ w.Header().Set("Content-Type", activitystreams)
w.Write(enc)
}