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

36
honk.go
View File

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