aboutsummaryrefslogtreecommitdiff
path: root/Database.go
diff options
context:
space:
mode:
authorFChannel <=>2021-01-25 11:02:42 -0800
committerFChannel <=>2021-01-25 11:02:42 -0800
commit3b923a6f098cacf35f309e44a4c67a6a576fba4e (patch)
tree967d50793a086b9b08d25a83f64f29089d1fcf6c /Database.go
parentf6ccb7e03ff6aff01acd7f2b40346156e7b8b10b (diff)
follow cache sync
Diffstat (limited to 'Database.go')
-rw-r--r--Database.go29
1 files changed, 19 insertions, 10 deletions
diff --git a/Database.go b/Database.go
index cdf23e7..313ffd8 100644
--- a/Database.go
+++ b/Database.go
@@ -214,16 +214,14 @@ func WriteObjectReplyToLocalDB(db *sql.DB, id string, replyto string) {
}
func writeObjectReplyToDB(db *sql.DB, obj ObjectBase) {
- for i, e := range obj.InReplyTo {
- if(i == 0 || IsReplyInThread(db, obj.InReplyTo[0].Id, e.Id)){
- query := `insert into replies (id, inreplyto) values ($1, $2)`
-
- _, err := db.Exec(query, obj.Id, e.Id)
-
- if err != nil{
- fmt.Println("error inserting replies")
- panic(err)
- }
+ for _, e := range obj.InReplyTo {
+ query := `insert into replies (id, inreplyto) values ($1, $2)`
+
+ _, err := db.Exec(query, obj.Id, e.Id)
+
+ if err != nil{
+ fmt.Println("error inserting replies")
+ panic(err)
}
update := true
@@ -242,6 +240,17 @@ func writeObjectReplyToDB(db *sql.DB, obj ObjectBase) {
}
}
}
+
+ if len(obj.InReplyTo) < 1 {
+ query := `insert into replies (id, inreplyto) values ($1, $2)`
+
+ _, err := db.Exec(query, obj.Id, "")
+
+ if err != nil{
+ fmt.Println("error inserting replies cache")
+ panic(err)
+ }
+ }
}
func WriteWalletToDB(db *sql.DB, obj ObjectBase) {