aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFChannel <=>2021-01-24 12:38:29 -0800
committerFChannel <=>2021-01-24 12:38:29 -0800
commitb62c79a0cff349ce475d67ed23bdd5d2e0470f76 (patch)
treeceb25d7c44c0ea048e164f034cb2bbad6ffbdbbb
parente3aac28acc5e776107c94c01a88bbd577380d6c5 (diff)
local actibity check
-rw-r--r--CacheDatabase.go49
-rw-r--r--main.go2
2 files changed, 27 insertions, 24 deletions
diff --git a/CacheDatabase.go b/CacheDatabase.go
index 93b3443..29bd4a0 100644
--- a/CacheDatabase.go
+++ b/CacheDatabase.go
@@ -278,37 +278,40 @@ func WriteObjectReplyToCache(db *sql.DB, obj ObjectBase) {
}
func WriteObjectReplyCache(db *sql.DB, obj ObjectBase) {
-
- for _, e := range obj.Replies.OrderedItems {
- query := `select inreplyto from cachereplies where id=$1`
+ if obj.Replies != nil {
+ for _, e := range obj.Replies.OrderedItems {
- rows, err := db.Query(query, obj.Id)
+ query := `select inreplyto from cachereplies where id=$1`
- CheckError(err, "error selecting obj id cache reply")
+ rows, err := db.Query(query, obj.Id)
- var inreplyto string
- defer rows.Close()
- rows.Next()
- rows.Scan(&inreplyto)
+ CheckError(err, "error selecting obj id cache reply")
- if inreplyto != "" {
- return
- }
-
- query = `insert into cachereplies (id, inreplyto) values ($1, $2)`
+ var inreplyto string
+ defer rows.Close()
+ rows.Next()
+ rows.Scan(&inreplyto)
- _, err = db.Exec(query, e.Id, obj.Id)
-
- if err != nil{
- fmt.Println("error inserting replies cache")
- panic(err)
- }
+ if inreplyto != "" {
+ return
+ }
+
+ query = `insert into cachereplies (id, inreplyto) values ($1, $2)`
- if !IsObjectLocal(db, e.Id) {
- WriteObjectToCache(db, e)
- }
+ _, err = db.Exec(query, e.Id, obj.Id)
+
+ if err != nil{
+ fmt.Println("error inserting replies cache")
+ panic(err)
+ }
+ if !IsObjectLocal(db, e.Id) {
+ WriteObjectToCache(db, e)
+ }
+
+ }
+ return
}
}
diff --git a/main.go b/main.go
index 874dc4d..7887138 100644
--- a/main.go
+++ b/main.go
@@ -1586,7 +1586,7 @@ func GetCollectionFromID(id string) Collection {
resp, err := http.DefaultClient.Do(req)
if err != nil {
- fmt.Println("could not get collection from " + id)
+ CheckError(err, "could not get collection from " + id)
return nColl
}