aboutsummaryrefslogtreecommitdiff
path: root/outboxGet.go
diff options
context:
space:
mode:
authorFChannel <=>2021-01-28 18:12:10 -0800
committerFChannel <=>2021-01-28 18:12:10 -0800
commit42e7acc965daea755a84064f68e4eebf3e3b2e11 (patch)
treed9c270771bcf0f9aac589d637435e920a14a519d /outboxGet.go
parente06b4e233382155808366538ed9075c3eeb351d2 (diff)
nil pointers .........
Diffstat (limited to 'outboxGet.go')
-rw-r--r--outboxGet.go42
1 files changed, 17 insertions, 25 deletions
diff --git a/outboxGet.go b/outboxGet.go
index 073a4bb..a42a3d7 100644
--- a/outboxGet.go
+++ b/outboxGet.go
@@ -93,7 +93,6 @@ func GetCollectionFromPath(db *sql.DB, path string) Collection {
func GetObjectFromPath(db *sql.DB, path string) ObjectBase{
var nObj ObjectBase
- var result []ObjectBase
query := `select id, name, content, type, published, attributedto, attachment, preview, actor from activitystream where id=$1 order by published desc`
@@ -102,37 +101,30 @@ func GetObjectFromPath(db *sql.DB, path string) ObjectBase{
CheckError(err, "error query collection path from db")
defer rows.Close()
+ rows.Next()
+ var attachID string
+ var previewID string
- for rows.Next(){
- var post ObjectBase
- var attachID string
- var previewID string
-
- var nActor Actor
- post.Actor = &nActor
-
- err = rows.Scan(&post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.AttributedTo, &attachID, &previewID, &post.Actor.Id)
-
- CheckError(err, "error scan object into post struct from path")
-
-
- var postCnt int
- var imgCnt int
- post.Replies, postCnt, imgCnt = GetObjectRepliesDB(db, post)
+ var nActor Actor
+ nObj.Actor = &nActor
+
+ err = rows.Scan(&nObj.Id, &nObj.Name, &nObj.Content, &nObj.Type, &nObj.Published, &nObj.AttributedTo, &attachID, &previewID, &nObj.Actor.Id)
+
+ CheckError(err, "error scan object into post struct from path")
- post.Replies.TotalItems, post.Replies.TotalImgs = GetObjectRepliesDBCount(db, post)
+ var postCnt int
+ var imgCnt int
- post.Replies.TotalItems = post.Replies.TotalItems + postCnt
- post.Replies.TotalImgs = post.Replies.TotalImgs + imgCnt
+ nObj.Replies, postCnt, imgCnt = GetObjectRepliesDB(db, nObj)
- post.Attachment = GetObjectAttachment(db, attachID)
+ nObj.Replies.TotalItems, nObj.Replies.TotalImgs = GetObjectRepliesDBCount(db, nObj)
- post.Preview = GetObjectPreview(db, previewID)
+ nObj.Replies.TotalItems = nObj.Replies.TotalItems + postCnt
+ nObj.Replies.TotalImgs = nObj.Replies.TotalImgs + imgCnt
- result = append(result, post)
- }
+ nObj.Attachment = GetObjectAttachment(db, attachID)
- nObj = result[0]
+ nObj.Preview = GetObjectPreview(db, previewID)
return nObj
}