allow unfollow by id

This commit is contained in:
Ted Unangst 2020-09-14 15:44:21 -04:00
parent f3a9f7711a
commit ec9f909473
2 changed files with 19 additions and 1 deletions

View File

@ -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")

5
web.go
View File

@ -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