diff options
-rw-r--r-- | CacheDatabase.go | 13 | ||||
-rw-r--r-- | Database.go | 6 | ||||
-rw-r--r-- | OutboxPost.go | 9 | ||||
-rw-r--r-- | main.go | 11 |
4 files changed, 13 insertions, 26 deletions
diff --git a/CacheDatabase.go b/CacheDatabase.go index 7b60bd6..e533f4f 100644 --- a/CacheDatabase.go +++ b/CacheDatabase.go @@ -360,7 +360,7 @@ func GetObjectRepliesCache(db *sql.DB, parent ObjectBase) (*CollectionBase, int, var postCnt int var imgCnt int - post.Replies, postCnt, imgCnt = GetObjectRepliesRepliesCache(db, post) + post.Replies, postCnt, imgCnt = GetObjectRepliesRepliesDB(db, post) post.Replies.TotalItems, post.Replies.TotalImgs = GetObjectRepliesCacheCount(db, post) @@ -376,17 +376,6 @@ func GetObjectRepliesCache(db *sql.DB, parent ObjectBase) (*CollectionBase, int, nColl.OrderedItems = result - - // remoteCollection, postc, imgc := GetObjectRepliesDB(db, parent) - - // for _, e := range remoteCollection.OrderedItems { - // nColl.OrderedItems = append(nColl.OrderedItems, e) - // postc = postc + 1 - // if len(e.Attachment) > 0 { - // imgc = imgc + 1 - // } - // } - return &nColl, 0, 0 } diff --git a/Database.go b/Database.go index 5a11f22..cbb035b 100644 --- a/Database.go +++ b/Database.go @@ -556,11 +556,8 @@ func GetObjectRepliesRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, result = append(result, post) } - /* - 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) @@ -572,7 +569,6 @@ func GetObjectRepliesRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, nColl.OrderedItems = result -*/ return &nColl, 0, 0 } diff --git a/OutboxPost.go b/OutboxPost.go index 898d9e8..262c7fd 100644 --- a/OutboxPost.go +++ b/OutboxPost.go @@ -506,16 +506,9 @@ func ParseInboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) { activity := GetActivityFromJson(r, db) switch(activity.Type) { case "Create": - for _, e := range activity.Object.InReplyTo { - if IsObjectLocal(db, e.Id) { - WriteObjectReplyToLocalDB(db, activity.Object.Id, e.Id) - } else if IsObjectCached(db, e.Id) { - WriteObjectToCache(db, *activity.Object) - } - } - for _, e := range activity.To { if IsActorLocal(db, e) { + fmt.Println("writing object to cache " + e) WriteObjectToCache(db, *activity.Object) } } @@ -1029,7 +1029,16 @@ func AddFollowersToActivity(db *sql.DB, activity Activity) Activity{ followers := GetActorFollowDB(db, activity.Actor.Id) for _, e := range followers { - activity.To = append(activity.To, e.Id) + var alreadyTo = false + for _, k := range activity.To { + if k == e.Id { + alreadyTo = true + } + } + + if !alreadyTo { + activity.To = append(activity.To, e.Id) + } } return activity |