cleanup intake a bit, fast path for delete

This commit is contained in:
Ted Unangst 2019-09-30 01:30:39 -04:00
parent 5de8ecf7b8
commit a333026b44
1 changed files with 78 additions and 73 deletions

View File

@ -201,9 +201,6 @@ func iszonked(userid int64, xid string) bool {
} }
func needxonk(user *WhatAbout, x *Honk) bool { func needxonk(user *WhatAbout, x *Honk) bool {
if x.What == "eradicate" {
return true
}
if thoudostbitethythumb(user.ID, x.Audience, x.XID) { if thoudostbitethythumb(user.ID, x.Audience, x.XID) {
log.Printf("not saving thumb biter? %s via %s", x.XID, x.Honker) log.Printf("not saving thumb biter? %s via %s", x.XID, x.Honker)
return false return false
@ -234,19 +231,18 @@ func needxonkid(user *WhatAbout, xid string) bool {
return true return true
} }
func savexonk(x *Honk) { func eradicatexonk(userid int64, xid string) {
if x.What == "eradicate" { xonk := getxonk(userid, xid)
log.Printf("eradicating %s by %s", x.XID, x.Honker)
xonk := getxonk(x.UserID, x.XID)
if xonk != nil { if xonk != nil {
deletehonk(xonk.ID) deletehonk(xonk.ID)
} }
_, err := stmtSaveZonker.Exec(x.UserID, x.XID, "zonk") _, err := stmtSaveZonker.Exec(userid, xid, "zonk")
if err != nil { if err != nil {
log.Printf("error eradicating: %s", err) log.Printf("error eradicating: %s", err)
} }
return }
}
func savexonk(x *Honk) {
log.Printf("saving xonk: %s", x.XID) log.Printf("saving xonk: %s", x.XID)
go prehandle(x.Honker) go prehandle(x.Honker)
go prehandle(x.Oonker) go prehandle(x.Oonker)
@ -470,6 +466,23 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
var ok bool var ok bool
isUpdate := false isUpdate := false
switch what { switch what {
case "Delete":
obj, ok = item.GetMap("object")
if ok {
xid, _ = obj.GetString("id")
} else {
xid, _ = item.GetString("object")
}
if xid == "" {
return nil
}
if originate(xid) != origin {
log.Printf("forged delete: %s", xid)
return nil
}
log.Printf("eradicating %s", xid)
eradicatexonk(user.ID, xid)
return nil
case "Announce": case "Announce":
obj, ok = item.GetMap("object") obj, ok = item.GetMap("object")
if ok { if ok {
@ -501,10 +514,6 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
} }
} }
what = "honk" what = "honk"
case "Delete":
obj, _ = item.GetMap("object")
xid, _ = item.GetString("object")
what = "eradicate"
case "Read": case "Read":
xid, ok = item.GetString("object") xid, ok = item.GetString("object")
if ok { if ok {
@ -569,9 +578,6 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
if ok { if ok {
dt = dt2 dt = dt2
} }
if ot == "Tombstone" {
xid, _ = obj.GetString("id")
} else {
xid, _ = obj.GetString("id") xid, _ = obj.GetString("id")
precis, _ = obj.GetString("summary") precis, _ = obj.GetString("summary")
if precis == "" { if precis == "" {
@ -629,7 +635,6 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
if what == "honk" && rid != "" { if what == "honk" && rid != "" {
what = "tonk" what = "tonk"
} }
}
atts, _ := obj.GetArray("attachment") atts, _ := obj.GetArray("attachment")
for i, atti := range atts { for i, atti := range atts {
att, ok := atti.(junk.Junk) att, ok := atti.(junk.Junk)