From 69fea996ad6e9577e356576573cd35cfc2eb03b9 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 29 Sep 2020 21:16:07 -0400 Subject: [PATCH] don't need to retry low prio communications --- activity.go | 26 +++++++++++++++++++------- deliverator.go | 8 +++++--- web.go | 2 +- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/activity.go b/activity.go index 5624b02..432b8be 100644 --- a/activity.go +++ b/activity.go @@ -997,7 +997,7 @@ func rubadubdub(user *WhatAbout, req junk.Junk) { j["published"] = time.Now().UTC().Format(time.RFC3339) j["object"] = req - deliverate(0, user.ID, actor, j.ToBytes()) + deliverate(0, user.ID, actor, j.ToBytes(), true) } func itakeitallback(user *WhatAbout, xid string, owner string, folxid string) { @@ -1016,7 +1016,7 @@ func itakeitallback(user *WhatAbout, xid string, owner string, folxid string) { j["object"] = f j["published"] = time.Now().UTC().Format(time.RFC3339) - deliverate(0, user.ID, owner, j.ToBytes()) + deliverate(0, user.ID, owner, j.ToBytes(), true) } func subsub(user *WhatAbout, xid string, owner string, folxid string) { @@ -1033,7 +1033,7 @@ func subsub(user *WhatAbout, xid string, owner string, folxid string) { j["object"] = xid j["published"] = time.Now().UTC().Format(time.RFC3339) - deliverate(0, user.ID, owner, j.ToBytes()) + deliverate(0, user.ID, owner, j.ToBytes(), true) } func activatedonks(donks []*Donk) []junk.Junk { @@ -1340,7 +1340,7 @@ func sendchonk(user *WhatAbout, ch *Chonk) { rcpts := make(map[string]bool) rcpts[ch.Target] = true for a := range rcpts { - go deliverate(0, user.ID, a, msg) + go deliverate(0, user.ID, a, msg, true) } } @@ -1375,13 +1375,25 @@ func honkworldwide(user *WhatAbout, honk *Honk) { } } for a := range rcpts { - go deliverate(0, user.ID, a, msg) + go deliverate(0, user.ID, a, msg, doesitmatter(honk.What)) } if honk.Public && len(honk.Onts) > 0 { collectiveaction(honk) } } +func doesitmatter(what string) bool { + switch what { + case "ack": + return false + case "react": + return false + case "deack": + return false + } + return true +} + func collectiveaction(honk *Honk) { user := getserveruser() for _, ont := range honk.Onts { @@ -1408,7 +1420,7 @@ func collectiveaction(honk *Honk) { } msg := j.ToBytes() for a := range rcpts { - go deliverate(0, user.ID, a, msg) + go deliverate(0, user.ID, a, msg, false) } } } @@ -1708,7 +1720,7 @@ func updateMe(username string) { } } for a := range rcpts { - go deliverate(0, user.ID, a, msg) + go deliverate(0, user.ID, a, msg, false) } } diff --git a/deliverator.go b/deliverator.go index 75ac382..6f7a08a 100644 --- a/deliverator.go +++ b/deliverator.go @@ -72,7 +72,7 @@ func clearoutbound(rcpt string) { var garage = gate.NewLimiter(40) -func deliverate(goarounds int64, userid int64, rcpt string, msg []byte) { +func deliverate(goarounds int64, userid int64, rcpt string, msg []byte, prio bool) { garage.Start() defer garage.Finish() @@ -99,7 +99,9 @@ func deliverate(goarounds int64, userid int64, rcpt string, msg []byte) { err := PostMsg(ki.keyname, ki.seckey, inbox, msg) if err != nil { log.Printf("failed to post json to %s: %s", inbox, err) - sayitagain(goarounds+1, userid, rcpt, msg) + if prio { + sayitagain(goarounds+1, userid, rcpt, msg) + } return } } @@ -162,7 +164,7 @@ func redeliverator() { continue } log.Printf("redeliverating %s try %d", rcpt, goarounds) - deliverate(goarounds, userid, rcpt, msg) + deliverate(goarounds, userid, rcpt, msg, true) } else if d.When.Before(nexttime) { nexttime = d.When } diff --git a/web.go b/web.go index ff0b0e7..9a5a67f 100644 --- a/web.go +++ b/web.go @@ -2287,7 +2287,7 @@ func apihandler(w http.ResponseWriter, r *http.Request) { rcpts := boxuprcpts(user, r.Form["rcpt"], public) msg := []byte(r.FormValue("msg")) for rcpt := range rcpts { - go deliverate(0, userid, rcpt, msg) + go deliverate(0, userid, rcpt, msg, true) } default: http.Error(w, "unknown action", http.StatusNotFound)