From ec9f9094735e9fa0e10626a17e9c878f1ee8f4a8 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 14 Sep 2020 15:44:21 -0400 Subject: [PATCH] allow unfollow by id --- activity.go | 15 ++++++++++++++- web.go | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/activity.go b/activity.go index ec8d694..b1f511e 100644 --- a/activity.go +++ b/activity.go @@ -1723,7 +1723,20 @@ func followme(user *WhatAbout, who string, name string, j junk.Junk) { } func unfollowme(user *WhatAbout, who string, name string, j junk.Junk) { - folxid, _ := j.GetString("id") + var folxid string + if who == "" { + folxid, _ = j.GetString("object") + + db := opendatabase() + row := db.QueryRow("select xid, name from honkers where userid = ? and folxid = ? and flavor in ('dub', 'undub')", user.ID, folxid) + err := row.Scan(&who, &name) + if err != nil { + if err != sql.ErrNoRows { + log.Printf("error scanning honker: %s", err) + } + return + } + } log.Printf("updating honker undo: %s %s", who, folxid) _, err := stmtUpdateFlavor.Exec("undub", folxid, user.ID, name, who, "dub") diff --git a/web.go b/web.go index 020e1f8..953aaba 100644 --- a/web.go +++ b/web.go @@ -399,6 +399,11 @@ func inbox(w http.ResponseWriter, r *http.Request) { case "Undo": obj, ok := j.GetMap("object") if !ok { + folxid, ok := j.GetString("object") + if ok && originate(folxid) == origin { + unfollowme(user, "", "", j) + return + } log.Printf("unknown undo no object") dumpactivity(j) return