From 9f26779377ce700b613ee684404b9add158ff182 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 21 Aug 2019 01:23:00 -0400 Subject: [PATCH] federate read/ignore activities for ack and deack --- activity.go | 21 +++++++++++++++++++++ honk.go | 36 ++++++++++++++++++++++++------------ 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/activity.go b/activity.go index e71593f..1e5d091 100644 --- a/activity.go +++ b/activity.go @@ -516,6 +516,21 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk { 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": @@ -873,6 +888,12 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) { 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 } return j, jo diff --git a/honk.go b/honk.go index b75527b..95709cc 100644 --- a/honk.go +++ b/honk.go @@ -947,15 +947,34 @@ func savebonk(w http.ResponseWriter, r *http.Request) { 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 } @@ -964,11 +983,14 @@ func zonkit(w http.ResponseWriter, r *http.Request) { 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 @@ func zonkit(w http.ResponseWriter, r *http.Request) { 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") } } }