federate read/ignore activities for ack and deack
Ted Unangst tedu@tedunangst.com
Wed, 21 Aug 2019 01:23:00 -0400
2 files changed,
45 insertions(+),
12 deletions(-)
M
activity.go
→
activity.go
@@ -516,6 +516,21 @@ case "Delete":
obj, _ = item.GetMap("object") xid, _ = item.GetString("object") what = "eradicate" + case "Read": + xid, ok = item.GetString("object") + if ok { + if !needxonkid(user, xid) { + log.Printf("don't need read obj: %s", xid) + return nil + } + obj, err = GetJunkHardMode(xid) + if err != nil { + log.Printf("error getting read: %s", err) + return nil + } + return xonkxonkfn(obj, originate(xid)) + } + return nil case "Video": fallthrough case "Question":@@ -872,6 +887,12 @@ }
j["object"] = h.XID case "zonk": j["type"] = "Delete" + j["object"] = h.XID + case "ack": + j["type"] = "Read" + j["object"] = h.XID + case "deack": + j["type"] = "Ignore" j["object"] = h.XID }
M
honk.go
→
honk.go
@@ -947,15 +947,34 @@
go honkworldwide(user, &bonk) } +func sendzonkofsorts(xonk *Honk, user *WhatAbout, what string) { + zonk := Honk{ + What: what, + XID: xonk.XID, + Date: time.Now().UTC(), + Audience: oneofakind(xonk.Audience), + } + zonk.Public = !keepitquiet(zonk.Audience) + + log.Printf("announcing %sed honk: %s", what, xonk.XID) + go honkworldwide(user, &zonk) +} + func zonkit(w http.ResponseWriter, r *http.Request) { wherefore := r.FormValue("wherefore") what := r.FormValue("what") + userinfo := login.GetUserInfo(r) + user, _ := butwhatabout(userinfo.Username) if wherefore == "ack" { _, err := stmtUpdateFlags.Exec(flagIsAcked, what) if err != nil { log.Printf("error acking: %s", err) } + xonk := getxonk(userinfo.UserID, what) + if xonk != nil { + sendzonkofsorts(xonk, user, "ack") + } return }@@ -963,12 +982,15 @@ if wherefore == "deack" {
_, err := stmtClearFlags.Exec(flagIsAcked, what) if err != nil { log.Printf("error deacking: %s", err) + } + xonk := getxonk(userinfo.UserID, what) + if xonk != nil { + sendzonkofsorts(xonk, user, "deack") } return } log.Printf("zonking %s %s", wherefore, what) - userinfo := login.GetUserInfo(r) if wherefore == "zonk" { xonk := getxonk(userinfo.UserID, what) if xonk != nil {@@ -981,17 +1003,7 @@ if err != nil {
log.Printf("error zonking: %s", err) } if xonk.Whofore == 2 || xonk.Whofore == 3 { - zonk := Honk{ - What: "zonk", - XID: xonk.XID, - Date: time.Now().UTC(), - Audience: oneofakind(xonk.Audience), - } - zonk.Public = !keepitquiet(zonk.Audience) - - user, _ := butwhatabout(userinfo.Username) - log.Printf("announcing deleted honk: %s", what) - go honkworldwide(user, &zonk) + sendzonkofsorts(xonk, user, "zonk") } } }