include userid in doover queries
Ted Unangst tedu@tedunangst.com
Mon, 12 Jun 2023 15:08:09 -0400
2 files changed,
5 insertions(+),
5 deletions(-)
M
database.go
→
database.go
@@ -1193,6 +1193,6 @@ stmtGetTracks = preparetodie(db, "select fetches from tracks where xid = ?")
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 = ?") }
M
deliverator.go
→
deliverator.go
@@ -68,10 +68,10 @@ }
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 @@ return true
} func deliverate(userid int64, rcpt string, msg []byte) { - if delinquent(rcpt, msg) { + if delinquent(userid, rcpt, msg) { return } var d Doover