diff options
author | FChannel <=> | 2021-01-24 22:30:56 -0800 |
---|---|---|
committer | FChannel <=> | 2021-01-24 22:30:56 -0800 |
commit | 3d307abbdf1c0ee711c80c753930a88014c8925a (patch) | |
tree | 6bceb0f4c4e47380206cb1c79fd8e2dee961adf4 | |
parent | a706133ba7c15f366dba66d10bf8f556147e40f1 (diff) |
reply feedback loop fix
-rw-r--r-- | CacheDatabase.go | 23 | ||||
-rw-r--r-- | Database.go | 9 |
2 files changed, 23 insertions, 9 deletions
diff --git a/CacheDatabase.go b/CacheDatabase.go index 035ffbb..992a160 100644 --- a/CacheDatabase.go +++ b/CacheDatabase.go @@ -228,6 +228,13 @@ func GetObjectFromCache(db *sql.DB, id string) Collection { var imgCnt int post.Replies, postCnt, imgCnt = GetObjectRepliesCache(db, post) + var localPost ObjectBase + localPost.Replies, postCnt, imgCnt = GetObjectRepliesDB(db, post) + + for _, e := range localPost.Replies.OrderedItems { + post.Replies.OrderedItems = append(post.Replies.OrderedItems, e) + } + post.Replies.TotalItems, post.Replies.TotalImgs = GetObjectRepliesCacheCount(db, post) post.Replies.TotalItems = post.Replies.TotalItems + postCnt @@ -371,6 +378,7 @@ func GetObjectRepliesCache(db *sql.DB, parent ObjectBase) (*CollectionBase, int, nColl.OrderedItems = result + /* remoteCollection := GetObjectRepliesRemote(db, parent) var postc int @@ -382,8 +390,9 @@ func GetObjectRepliesCache(db *sql.DB, parent ObjectBase) (*CollectionBase, int, imgc = imgc + 1 } } +*/ - return &nColl, postc, imgc + return &nColl, 0, 0 } func GetObjectRepliesRepliesCache(db *sql.DB, parent ObjectBase) (*CollectionBase, int, int) { @@ -420,6 +429,7 @@ func GetObjectRepliesRepliesCache(db *sql.DB, parent ObjectBase) (*CollectionBas result = append(result, post) } + /* remoteCollection := GetObjectRepliesRemote(db, parent) var postc int @@ -434,8 +444,9 @@ func GetObjectRepliesRepliesCache(db *sql.DB, parent ObjectBase) (*CollectionBas } nColl.OrderedItems = result +*/ - return &nColl, postc, imgc + return &nColl, 0, 0 } func GetObjectRepliesCacheCount(db *sql.DB, parent ObjectBase) (int, int) { @@ -578,7 +589,6 @@ func GetObjectImgsTotalCache(db *sql.DB, actor Actor) int{ } func DeleteActorCache(db *sql.DB, actorID string) { - fmt.Println("delete actor to cache") query := `select id from cacheactivitystream where id in (select id from cacheactivitystream where actor=$1)` rows, err := db.Query(query, actorID) @@ -598,11 +608,10 @@ func DeleteActorCache(db *sql.DB, actorID string) { } func WriteActorToCache(db *sql.DB, actorID string) { - fmt.Println("writing actor to cache") actor := GetActor(actorID) collection := GetActorCollection(actor.Outbox) - for _, e := range collection.OrderedItems { - WriteObjectToCache(db, e) - } + for _, e := range collection.OrderedItems { + WriteObjectToCache(db, e) + } } diff --git a/Database.go b/Database.go index cce0fcd..9ebf000 100644 --- a/Database.go +++ b/Database.go @@ -470,6 +470,7 @@ func GetObjectRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, int, in nColl.OrderedItems = result + /* remoteCollection := GetObjectRepliesRemote(db, parent) var postc int @@ -481,8 +482,9 @@ func GetObjectRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, int, in imgc = imgc + 1 } } +*/ - return &nColl, postc, imgc + return &nColl, 0, 0 } func GetObjectRepliesRemote(db *sql.DB, parent ObjectBase) CollectionBase { @@ -552,6 +554,7 @@ func GetObjectRepliesRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, result = append(result, post) } + /* remoteCollection := GetObjectRepliesRemote(db, parent) var postc int @@ -565,9 +568,11 @@ func GetObjectRepliesRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, } } + nColl.OrderedItems = result +*/ - return &nColl, postc, imgc + return &nColl, 0, 0 } func GetObjectRepliesDBCount(db *sql.DB, parent ObjectBase) (int, int) { |