rework all the follow stuff a bit
Ted Unangst tedu@tedunangst.com
Mon, 10 Jun 2019 23:57:03 -0400
2 files changed,
20 insertions(+),
41 deletions(-)
M
activity.go
→
activity.go
@@ -648,32 +648,24 @@ }
func rubadubdub(user *WhatAbout, req map[string]interface{}) { xid, _ := jsongetstring(req, "id") - reqactor, _ := jsongetstring(req, "actor") + actor, _ := jsongetstring(req, "actor") j := NewJunk() j["@context"] = itiswhatitis j["id"] = user.URL + "/dub/" + xid j["type"] = "Accept" j["actor"] = user.URL - j["to"] = reqactor + j["to"] = actor j["published"] = time.Now().UTC().Format(time.RFC3339) j["object"] = req - actor, _ := jsongetstring(req, "actor") - box, err := getboxes(actor) - if err != nil { - log.Printf("can't get dub box: %s", err) - return - } - keyname, key := ziggy(user.Name) - err = PostJunk(keyname, key, box.In, j) - if err != nil { - log.Printf("can't rub a dub: %s", err) - return - } - stmtSaveDub.Exec(user.ID, actor, actor, "dub") + var buf bytes.Buffer + WriteJunk(&buf, j) + msg := buf.Bytes() + + deliverate(0, user.Name, actor, msg) } -func itakeitallback(user *WhatAbout, xid string) error { +func itakeitallback(user *WhatAbout, xid string) { j := NewJunk() j["@context"] = itiswhatitis j["id"] = user.URL + "/unsub/" + xid@@ -688,16 +680,11 @@ f["to"] = xid
j["object"] = f j["published"] = time.Now().UTC().Format(time.RFC3339) - box, err := getboxes(xid) - if err != nil { - return err - } - keyname, key := ziggy(user.Name) - err = PostJunk(keyname, key, box.In, j) - if err != nil { - return err - } - return nil + var buf bytes.Buffer + WriteJunk(&buf, j) + msg := buf.Bytes() + + deliverate(0, user.Name, xid, msg) } func subsub(user *WhatAbout, xid string) {@@ -710,16 +697,11 @@ j["to"] = xid
j["object"] = xid j["published"] = time.Now().UTC().Format(time.RFC3339) - a := xid - box, _ := getboxes(xid) - if box != nil { - a = "%" + box.In - } var buf bytes.Buffer WriteJunk(&buf, j) msg := buf.Bytes() - deliverate(0, user.Name, a, msg) + deliverate(0, user.Name, xid, msg) } func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]interface{}) {
M
honk.go
→
honk.go
@@ -328,7 +328,8 @@ case "Follow":
obj, _ := jsongetstring(j, "object") if obj == user.URL { log.Printf("updating honker follow: %s", who) - rubadubdub(user, j) + stmtSaveDub.Exec(user.ID, who, who, "dub") + go rubadubdub(user, j) } else { log.Printf("can't follow %s", obj) }@@ -1052,15 +1053,11 @@ return
} log.Printf("unsubscribing from %s", xid) user, _ := butwhatabout(u.Username) - err = itakeitallback(user, xid) + go itakeitallback(user, xid) + _, err = stmtUpdateFlavor.Exec("unsub", u.UserID, xid, "sub") if err != nil { - log.Printf("can't take it back: %s", err) - } else { - _, err = stmtUpdateFlavor.Exec("unsub", u.UserID, xid, "sub") - if err != nil { - log.Printf("error updating honker: %s", err) - return - } + log.Printf("error updating honker: %s", err) + return } http.Redirect(w, r, "/honkers", http.StatusSeeOther)