aboutsummaryrefslogtreecommitdiff
path: root/db/local.go
diff options
context:
space:
mode:
authorKushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com>2021-10-30 00:28:51 -0300
committerFChannel <>2022-06-19 12:53:29 -0700
commit8040825daac4a5ba24e947c4c657d169d7763543 (patch)
tree667058707ab1c2b2af5dc01decda25cc7709f9df /db/local.go
parentf76b8093b9ca69c7d4eca747d8c5d702d492e1fb (diff)
restructuring, part 3 of many
Diffstat (limited to 'db/local.go')
-rw-r--r--db/local.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/db/local.go b/db/local.go
new file mode 100644
index 0000000..7cb46d1
--- /dev/null
+++ b/db/local.go
@@ -0,0 +1,42 @@
+package db
+
+func IsIDLocal(id string) (bool, error) {
+ activity, err := GetActivityFromDB(id)
+ return len(activity.OrderedItems) > 0, err
+}
+
+func IsActorLocal(id string) (bool, error) {
+ actor, err := GetActorFromDB(id)
+ return actor.Id != "", err
+}
+
+func IsObjectLocal(id string) (bool, error) {
+ query := `select id from activitystream where id=$1`
+
+ rows, err := db.Query(query, id)
+ if err != nil {
+ return false, err
+ }
+
+ var nID string
+ defer rows.Close()
+
+ rows.Next()
+ err = rows.Scan(&nID)
+ return nID != "", err
+}
+
+func IsObjectCached(id string) (bool, error) {
+ query := `select id from cacheactivitystream where id=$1`
+ rows, err := db.Query(query, id)
+ if err != nil {
+ return false, err
+ }
+
+ var nID string
+ defer rows.Close()
+
+ rows.Next()
+ err = rows.Scan(&nID)
+ return nID != "", err
+}