diff options
author | FChannel <=> | 2021-01-25 11:02:42 -0800 |
---|---|---|
committer | FChannel <=> | 2021-01-25 11:02:42 -0800 |
commit | 3b923a6f098cacf35f309e44a4c67a6a576fba4e (patch) | |
tree | 967d50793a086b9b08d25a83f64f29089d1fcf6c /Database.go | |
parent | f6ccb7e03ff6aff01acd7f2b40346156e7b8b10b (diff) |
follow cache sync
Diffstat (limited to 'Database.go')
-rw-r--r-- | Database.go | 29 |
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) { |