aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Database.go53
-rw-r--r--config-init2
-rw-r--r--outboxGet.go15
3 files changed, 52 insertions, 18 deletions
diff --git a/Database.go b/Database.go
index 7f69efe..bf6ff82 100644
--- a/Database.go
+++ b/Database.go
@@ -305,10 +305,15 @@ func GetActivityFromDB(db *sql.DB, id string) Collection {
post.Actor = &actor
- post.Replies = GetObjectRepliesDB(db, post)
+ var postCnt int
+ var imgCnt int
+ post.Replies, postCnt, imgCnt = GetObjectRepliesDB(db, post)
post.Replies.TotalItems, post.Replies.TotalImgs = GetObjectRepliesDBCount(db, post)
+ post.Replies.TotalItems = post.Replies.TotalItems + postCnt
+ post.Replies.TotalImgs = post.Replies.TotalImgs + imgCnt
+
post.Attachment = GetObjectAttachment(db, attachID)
post.Preview = GetObjectPreview(db, previewID)
@@ -344,10 +349,15 @@ func GetObjectFromDB(db *sql.DB, actor Actor) Collection {
post.Actor = &actor
- post.Replies = GetObjectRepliesDB(db, post)
+ var postCnt int
+ var imgCnt int
+ post.Replies, postCnt, imgCnt = GetObjectRepliesDB(db, post)
post.Replies.TotalItems, post.Replies.TotalImgs = GetObjectRepliesDBCount(db, post)
+ post.Replies.TotalItems = post.Replies.TotalItems + postCnt
+ post.Replies.TotalImgs = post.Replies.TotalImgs + imgCnt
+
post.Attachment = GetObjectAttachment(db, attachID)
post.Preview = GetObjectPreview(db, previewID)
@@ -382,7 +392,7 @@ func GetInReplyToDB(db *sql.DB, parent ObjectBase) []ObjectBase {
}
-func GetObjectRepliesDB(db *sql.DB, parent ObjectBase) *CollectionBase {
+func GetObjectRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, int, int) {
var nColl CollectionBase
var result []ObjectBase
@@ -408,10 +418,15 @@ func GetObjectRepliesDB(db *sql.DB, parent ObjectBase) *CollectionBase {
CheckError(err, "error with replies db scan")
post.Actor = &actor
-
- post.Replies = GetObjectRepliesRepliesDB(db, post)
- post.Replies.TotalItems, post.Replies.TotalImgs = GetObjectRepliesDBCount(db, post)
+ var postCnt int
+ var imgCnt int
+ post.Replies, postCnt, imgCnt = GetObjectRepliesRepliesDB(db, post)
+
+ post.Replies.TotalItems, post.Replies.TotalImgs = GetObjectRepliesDBCount(db, post)
+
+ post.Replies.TotalItems = post.Replies.TotalItems + postCnt
+ post.Replies.TotalImgs = post.Replies.TotalImgs + imgCnt
post.Attachment = GetObjectAttachment(db, attachID)
@@ -424,13 +439,18 @@ func GetObjectRepliesDB(db *sql.DB, parent ObjectBase) *CollectionBase {
remoteCollection := GetObjectRepliesRemote(db, parent)
+ var postc int
+ var imgc int
for _, e := range remoteCollection.OrderedItems {
-
+
nColl.OrderedItems = append(nColl.OrderedItems, e)
-
+ postc = postc + 1
+ if len(e.Attachment) > 0 {
+ imgc = imgc + 1
+ }
}
- return &nColl
+ return &nColl, postc, imgc
}
func GetObjectRepliesRemote(db *sql.DB, parent ObjectBase) CollectionBase {
@@ -459,7 +479,7 @@ func GetObjectRepliesRemote(db *sql.DB, parent ObjectBase) CollectionBase {
return nColl
}
-func GetObjectRepliesRepliesDB(db *sql.DB, parent ObjectBase) *CollectionBase {
+func GetObjectRepliesRepliesDB(db *sql.DB, parent ObjectBase) (*CollectionBase, int, int) {
var nColl CollectionBase
var result []ObjectBase
@@ -495,15 +515,20 @@ func GetObjectRepliesRepliesDB(db *sql.DB, parent ObjectBase) *CollectionBase {
remoteCollection := GetObjectRepliesRemote(db, parent)
+ var postc int
+ var imgc int
for _, e := range remoteCollection.OrderedItems {
nColl.OrderedItems = append(nColl.OrderedItems, e)
-
+ postc = postc + 1
+ if len(e.Attachment) > 0 {
+ imgc = imgc + 1
+ }
}
nColl.OrderedItems = result
- return &nColl
+ return &nColl, postc, imgc
}
func GetObjectRepliesDBCount(db *sql.DB, parent ObjectBase) (int, int) {
@@ -531,9 +556,7 @@ func GetObjectRepliesDBCount(db *sql.DB, parent ObjectBase) (int, int) {
rows.Next()
rows.Scan(&countImg)
- post, img := GetObjectRepliesRemoteCount(db, parent)
-
- return countId + post, countImg + img
+ return countId, countImg
}
func GetObjectRepliesRemoteCount(db *sql.DB, parent ObjectBase) (int, int) {
diff --git a/config-init b/config-init
index f8173ea..7da7b26 100644
--- a/config-init
+++ b/config-init
@@ -11,7 +11,7 @@ dbuser:postgres
dbpass:password
emailserver:
-emailport
+emailport:
emailaddress:
emailpass:
diff --git a/outboxGet.go b/outboxGet.go
index 665ca05..1065ad9 100644
--- a/outboxGet.go
+++ b/outboxGet.go
@@ -68,10 +68,15 @@ func GetCollectionFromPath(db *sql.DB, path string) Collection {
post.InReplyTo = GetInReplyToDB(db, post)
- post.Replies = GetObjectRepliesDB(db, post)
+ var postCnt int
+ var imgCnt int
+ post.Replies, postCnt, imgCnt = GetObjectRepliesDB(db, post)
post.Replies.TotalItems, post.Replies.TotalImgs = GetObjectRepliesDBCount(db, post)
+ post.Replies.TotalItems = post.Replies.TotalItems + postCnt
+ post.Replies.TotalImgs = post.Replies.TotalImgs + imgCnt
+
post.Attachment = GetObjectAttachment(db, attachID)
post.Preview = GetObjectPreview(db, previewID)
@@ -108,10 +113,16 @@ func GetObjectFromPath(db *sql.DB, path string) ObjectBase{
CheckError(err, "error scan object into post struct from path")
- post.Replies = GetObjectRepliesDB(db, post)
+
+ var postCnt int
+ var imgCnt int
+ post.Replies, postCnt, imgCnt = GetObjectRepliesDB(db, post)
post.Replies.TotalItems, post.Replies.TotalImgs = GetObjectRepliesDBCount(db, post)
+ post.Replies.TotalItems = post.Replies.TotalItems + postCnt
+ post.Replies.TotalImgs = post.Replies.TotalImgs + imgCnt
+
post.Attachment = GetObjectAttachment(db, attachID)
post.Preview = GetObjectPreview(db, previewID)