aboutsummaryrefslogtreecommitdiff
path: root/db/outbox.go
diff options
context:
space:
mode:
authorFChannel <>2022-04-30 11:00:55 -0700
committerFChannel <>2022-06-19 12:53:29 -0700
commit1892327cee2c3fa1d3bea729bd08eb63c2189a96 (patch)
tree7b846f7d9caf46fba6c9d15ff81b9d89dcca9476 /db/outbox.go
parent5b52d269faa2ce2014d0feba603a2122361cf4eb (diff)
restructured code base to prevent circular dependicies
Diffstat (limited to 'db/outbox.go')
-rw-r--r--db/outbox.go116
1 files changed, 0 insertions, 116 deletions
diff --git a/db/outbox.go b/db/outbox.go
deleted file mode 100644
index e8189d9..0000000
--- a/db/outbox.go
+++ /dev/null
@@ -1,116 +0,0 @@
-package db
-
-import (
- "github.com/FChannel0/FChannel-Server/activitypub"
-)
-
-func GetCollectionFromPath(path string) (activitypub.Collection, error) {
- var nColl activitypub.Collection
- var result []activitypub.ObjectBase
-
- query := `select id, name, content, type, published, attributedto, attachment, preview, actor from activitystream where id=$1 order by published desc`
-
- rows, err := db.Query(query, path)
- if err != nil {
- return nColl, err
- }
- defer rows.Close()
-
- for rows.Next() {
- var actor activitypub.Actor
- var post activitypub.ObjectBase
- var attachID string
- var previewID string
-
- if err := rows.Scan(&post.Id, &post.Name, &post.Content, &post.Type, &post.Published, &post.AttributedTo, &attachID, &previewID, &actor.Id); err != nil {
- return nColl, err
- }
-
- post.Actor = actor.Id
-
- post.InReplyTo, err = GetInReplyToDB(post)
- if err != nil {
- return nColl, err
- }
-
- var postCnt int
- var imgCnt int
- post.Replies, postCnt, imgCnt, err = GetObjectRepliesDB(post)
- if err != nil {
- return nColl, err
- }
-
- post.Replies.TotalItems, post.Replies.TotalImgs, err = GetObjectRepliesCount(post)
- if err != nil {
- return nColl, err
- }
-
- post.Replies.TotalItems = post.Replies.TotalItems + postCnt
- post.Replies.TotalImgs = post.Replies.TotalImgs + imgCnt
-
- post.Attachment, err = GetObjectAttachment(attachID)
- if err != nil {
- return nColl, err
- }
-
- post.Preview, err = GetObjectPreview(previewID)
- if err != nil {
- return nColl, err
- }
-
- result = append(result, post)
- }
-
- nColl.AtContext.Context = "https://www.w3.org/ns/activitystreams"
-
- nColl.OrderedItems = result
-
- return nColl, nil
-}
-
-func GetObjectFromPath(path string) (activitypub.ObjectBase, error) {
- var nObj activitypub.ObjectBase
-
- query := `select id, name, content, type, published, attributedto, attachment, preview, actor from activitystream where id=$1 order by published desc`
-
- rows, err := db.Query(query, path)
- if err != nil {
- return nObj, err
- }
-
- defer rows.Close()
- rows.Next()
- var attachID string
- var previewID string
-
- var nActor activitypub.Actor
- nObj.Actor = nActor.Id
-
- if err := rows.Scan(&nObj.Id, &nObj.Name, &nObj.Content, &nObj.Type, &nObj.Published, &nObj.AttributedTo, &attachID, &previewID, &nObj.Actor); err != nil {
- return nObj, err
- }
-
- var postCnt int
- var imgCnt int
-
- nObj.Replies, postCnt, imgCnt, err = GetObjectRepliesDB(nObj)
- if err != nil {
- return nObj, err
- }
-
- nObj.Replies.TotalItems, nObj.Replies.TotalImgs, err = GetObjectRepliesCount(nObj)
- if err != nil {
- return nObj, err
- }
-
- nObj.Replies.TotalItems = nObj.Replies.TotalItems + postCnt
- nObj.Replies.TotalImgs = nObj.Replies.TotalImgs + imgCnt
-
- nObj.Attachment, err = GetObjectAttachment(attachID)
- if err != nil {
- return nObj, err
- }
-
- nObj.Preview, err = GetObjectPreview(previewID)
- return nObj, err
-}