federate read/ignore activities for ack and deack

This commit is contained in:
Ted Unangst 2019-08-21 01:23:00 -04:00
parent 046d473d0f
commit 9f26779377
2 changed files with 45 additions and 12 deletions

View File

@ -516,6 +516,21 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
obj, _ = item.GetMap("object") obj, _ = item.GetMap("object")
xid, _ = item.GetString("object") xid, _ = item.GetString("object")
what = "eradicate" 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": case "Video":
fallthrough fallthrough
case "Question": case "Question":
@ -873,6 +888,12 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
case "zonk": case "zonk":
j["type"] = "Delete" j["type"] = "Delete"
j["object"] = h.XID 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 return j, jo

36
honk.go
View File

@ -947,15 +947,34 @@ func savebonk(w http.ResponseWriter, r *http.Request) {
go honkworldwide(user, &bonk) 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) { func zonkit(w http.ResponseWriter, r *http.Request) {
wherefore := r.FormValue("wherefore") wherefore := r.FormValue("wherefore")
what := r.FormValue("what") what := r.FormValue("what")
userinfo := login.GetUserInfo(r)
user, _ := butwhatabout(userinfo.Username)
if wherefore == "ack" { if wherefore == "ack" {
_, err := stmtUpdateFlags.Exec(flagIsAcked, what) _, err := stmtUpdateFlags.Exec(flagIsAcked, what)
if err != nil { if err != nil {
log.Printf("error acking: %s", err) log.Printf("error acking: %s", err)
} }
xonk := getxonk(userinfo.UserID, what)
if xonk != nil {
sendzonkofsorts(xonk, user, "ack")
}
return return
} }
@ -964,11 +983,14 @@ func zonkit(w http.ResponseWriter, r *http.Request) {
if err != nil { if err != nil {
log.Printf("error deacking: %s", err) log.Printf("error deacking: %s", err)
} }
xonk := getxonk(userinfo.UserID, what)
if xonk != nil {
sendzonkofsorts(xonk, user, "deack")
}
return return
} }
log.Printf("zonking %s %s", wherefore, what) log.Printf("zonking %s %s", wherefore, what)
userinfo := login.GetUserInfo(r)
if wherefore == "zonk" { if wherefore == "zonk" {
xonk := getxonk(userinfo.UserID, what) xonk := getxonk(userinfo.UserID, what)
if xonk != nil { if xonk != nil {
@ -981,17 +1003,7 @@ func zonkit(w http.ResponseWriter, r *http.Request) {
log.Printf("error zonking: %s", err) log.Printf("error zonking: %s", err)
} }
if xonk.Whofore == 2 || xonk.Whofore == 3 { if xonk.Whofore == 2 || xonk.Whofore == 3 {
zonk := Honk{ sendzonkofsorts(xonk, user, "zonk")
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)
} }
} }
} }