diff options
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) { |