From 86f05b716623a1d6738d4d00ebf0b5644d385033 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 6 Oct 2019 21:57:31 -0400 Subject: [PATCH] update follow request instead of creating dupes --- web.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/web.go b/web.go index c788a42..125a7d6 100644 --- a/web.go +++ b/web.go @@ -324,7 +324,20 @@ func inbox(w http.ResponseWriter, r *http.Request) { 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)