diff options
author | FChannel <=> | 2021-01-25 14:14:27 -0800 |
---|---|---|
committer | FChannel <=> | 2021-01-25 14:14:27 -0800 |
commit | d94cbd3375df4cd01d068f56da1c6e4b0acd693c (patch) | |
tree | 363cc205bfd350c205f26cb23c8a1c05df6df897 | |
parent | aa76455a3dfd4504697e1b3fdb33e0aeb01db4d7 (diff) |
removed duplicated To fields
-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 |