all repos — honk @ 29e3db72ba1159e40932bb8af9b87ebd579d19a5

my fork of honk

update follow request instead of creating dupes
Ted Unangst tedu@tedunangst.com
Sun, 06 Oct 2019 21:57:31 -0400
commit

29e3db72ba1159e40932bb8af9b87ebd579d19a5

parent

4ca86dfac2c0f16b06b955d69b22e0ab2d0c87d8

1 files changed, 14 insertions(+), 1 deletions(-)

jump to
M web.goweb.go

@@ -324,7 +324,20 @@ case "Follow":

obj, _ := j.GetString("object") if obj == user.URL { log.Printf("updating honker follow: %s", who) - stmtSaveDub.Exec(user.ID, who, who, "dub") + + db := opendatabase() + row := db.QueryRow("select xid from honkers where xid = ? and userid = ? and flavor in ('dub', 'undub')", who, user.ID) + var x string + err = row.Scan(&x) + if err != sql.ErrNoRows { + log.Printf("duplicate follow request: %s", who) + _, err = stmtUpdateFlavor.Exec("dub", user.ID, who, "undub") + if err != nil { + log.Printf("error updating honker: %s", err) + } + } else { + stmtSaveDub.Exec(user.ID, who, who, "dub") + } go rubadubdub(user, j) } else { log.Printf("can't follow %s", obj)