diff --git a/activity.go b/activity.go index 078e6bf..ec8d694 100644 --- a/activity.go +++ b/activity.go @@ -1702,7 +1702,9 @@ func updateMe(username string) { } func followme(user *WhatAbout, who string, name string, j junk.Junk) { - log.Printf("updating honker follow: %s", who) + folxid, _ := j.GetString("id") + + log.Printf("updating honker follow: %s %s", who, folxid) var x string db := opendatabase() @@ -1710,19 +1712,21 @@ func followme(user *WhatAbout, who string, name string, j junk.Junk) { err := row.Scan(&x) if err != sql.ErrNoRows { log.Printf("duplicate follow request: %s", who) - _, err = stmtUpdateFlavor.Exec("dub", user.ID, name, who, "undub") + _, err = stmtUpdateFlavor.Exec("dub", folxid, user.ID, name, who, "undub") if err != nil { log.Printf("error updating honker: %s", err) } } else { - stmtSaveDub.Exec(user.ID, name, who, "dub") + stmtSaveDub.Exec(user.ID, name, who, "dub", folxid) } go rubadubdub(user, j) } func unfollowme(user *WhatAbout, who string, name string, j junk.Junk) { - log.Printf("updating honker undo: %s", who) - _, err := stmtUpdateFlavor.Exec("undub", user.ID, name, who, "dub") + folxid, _ := j.GetString("id") + + log.Printf("updating honker undo: %s %s", who, folxid) + _, err := stmtUpdateFlavor.Exec("undub", folxid, user.ID, name, who, "dub") if err != nil { log.Printf("error updating honker: %s", err) return @@ -1772,16 +1776,16 @@ func followyou2(user *WhatAbout, j junk.Junk) { who, _ := j.GetString("actor") log.Printf("updating honker accept: %s", who) - var name string db := opendatabase() - row := db.QueryRow("select name from honkers where userid = ? and xid = ? and flavor in ('presub')", + row := db.QueryRow("select name, folxid from honkers where userid = ? and xid = ? and flavor in ('presub')", user.ID, who) - err := row.Scan(&name) + var name, folxid string + err := row.Scan(&name, &folxid) if err != nil { log.Printf("can't get honker name: %s", err) return } - _, err = stmtUpdateFlavor.Exec("sub", user.ID, name, who, "presub") + _, err = stmtUpdateFlavor.Exec("sub", folxid, user.ID, name, who, "presub") if err != nil { log.Printf("error updating honker: %s", err) return diff --git a/database.go b/database.go index 2b0d337..8570213 100644 --- a/database.go +++ b/database.go @@ -234,7 +234,7 @@ func gethonksforme(userid int64, wanted int64) []*Honk { } func gethonksfromlongago(userid int64, wanted int64) []*Honk { now := time.Now().UTC() - now = time.Date(now.Year() - 1, now.Month(), now.Day(), now.Hour(), now.Minute(), + now = time.Date(now.Year()-1, now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second(), 0, now.Location()) dt1 := now.Add(-36 * time.Hour).Format(dbtimeformat) dt2 := now.Add(12 * time.Hour).Format(dbtimeformat) @@ -883,7 +883,7 @@ func preparetodie(db *sql.DB, s string) *sql.Stmt { func prepareStatements(db *sql.DB) { stmtHonkers = preparetodie(db, "select honkerid, userid, name, xid, flavor, combos, meta from honkers where userid = ? and (flavor = 'presub' or flavor = 'sub' or flavor = 'peep' or flavor = 'unsub') order by name") stmtSaveHonker = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos, owner, meta, folxid) values (?, ?, ?, ?, ?, ?, ?, '')") - stmtUpdateFlavor = preparetodie(db, "update honkers set flavor = ? where userid = ? and name = ? and xid = ? and flavor = ?") + stmtUpdateFlavor = preparetodie(db, "update honkers set flavor = ?, folxid = ? where userid = ? and name = ? and xid = ? and flavor = ?") stmtUpdateHonker = preparetodie(db, "update honkers set name = ?, combos = ?, meta = ? where honkerid = ? and userid = ?") stmtOneHonker = preparetodie(db, "select xid from honkers where name = ? and userid = ?") stmtDubbers = preparetodie(db, "select honkerid, userid, name, xid, flavor from honkers where userid = ? and flavor = 'dub'") @@ -929,7 +929,7 @@ func prepareStatements(db *sql.DB) { stmtFindFile = preparetodie(db, "select fileid, xid from filemeta where url = ? and local = 1") stmtUserByName = preparetodie(db, "select userid, username, displayname, about, pubkey, seckey, options from users where username = ? and userid > 0") stmtUserByNumber = preparetodie(db, "select userid, username, displayname, about, pubkey, seckey, options from users where userid = ?") - stmtSaveDub = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos, owner, meta, folxid) values (?, ?, ?, ?, '', '', '', '')") + stmtSaveDub = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos, owner, meta, folxid) values (?, ?, ?, ?, '', '', '', ?)") stmtAddDoover = preparetodie(db, "insert into doovers (dt, tries, userid, rcpt, msg) values (?, ?, ?, ?, ?)") stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers") stmtLoadDoover = preparetodie(db, "select tries, userid, rcpt, msg from doovers where dooverid = ?") diff --git a/upgradedb.go b/upgradedb.go index b98a239..e5e37c5 100644 --- a/upgradedb.go +++ b/upgradedb.go @@ -23,7 +23,7 @@ import ( "time" ) -var myVersion = 38 +var myVersion = 39 type dbexecer interface { Exec(query string, args ...interface{}) (sql.Result, error) @@ -164,6 +164,10 @@ func upgradedb() { doordie(db, "update config set value = 38 where key = 'dbversion'") fallthrough case 38: + doordie(db, "update honkers set folxid = abs(random())") + doordie(db, "update config set value = 39 where key = 'dbversion'") + fallthrough + case 39: default: log.Fatalf("can't upgrade unknown version %d", dbversion)