From 3baff9e64e45ce5d1dc25a4989a1d03ed649aaf4 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 12 Jun 2023 15:08:09 -0400 Subject: [PATCH] include userid in doover queries --- database.go | 4 ++-- deliverator.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/database.go b/database.go index 1ef5cb1..1edbe1a 100644 --- a/database.go +++ b/database.go @@ -1193,6 +1193,6 @@ func prepareStatements(db *sql.DB) { stmtSaveChonk = preparetodie(db, "insert into chonks (userid, xid, who, target, dt, noise, format) values (?, ?, ?, ?, ?, ?, ?)") stmtLoadChonks = preparetodie(db, "select chonkid, userid, xid, who, target, dt, noise, format from chonks where userid = ? and dt > ? order by chonkid asc") stmtGetChatters = preparetodie(db, "select distinct(target) from chonks where userid = ?") - stmtDeliquentCheck = preparetodie(db, "select dooverid, msg from doovers where rcpt = ?") - stmtDeliquentUpdate = preparetodie(db, "update doovers set data = ? where dooverid = ?") + stmtDeliquentCheck = preparetodie(db, "select dooverid, msg from doovers where userid = ? and rcpt = ?") + stmtDeliquentUpdate = preparetodie(db, "update doovers set msg = ? where dooverid = ?") } diff --git a/deliverator.go b/deliverator.go index 67ec737..b3491c5 100644 --- a/deliverator.go +++ b/deliverator.go @@ -68,10 +68,10 @@ func sayitagain(doover Doover) { var dqmtx sync.Mutex -func delinquent(rcpt string, msg []byte) bool { +func delinquent(userid int64, rcpt string, msg []byte) bool { dqmtx.Lock() defer dqmtx.Unlock() - row := stmtDeliquentCheck.QueryRow(rcpt) + row := stmtDeliquentCheck.QueryRow(userid, rcpt) var dooverid int64 var data []byte err := row.Scan(&dooverid, data) @@ -93,7 +93,7 @@ func delinquent(rcpt string, msg []byte) bool { } func deliverate(userid int64, rcpt string, msg []byte) { - if delinquent(rcpt, msg) { + if delinquent(userid, rcpt, msg) { return } var d Doover