delete all the bloat
Ted Unangst tedu@tedunangst.com
Fri, 16 Aug 2019 00:28:16 -0400
M
bloat.go
→
bloat.go
@@ -14,95 +14,3 @@ // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. package main - -import ( - "bytes" - "fmt" - "log" - "strings" - "sync" -) - -var bloat_mtx sync.Mutex - -func bloat_counterplusone(s string) string { - bloat_mtx.Lock() - defer bloat_mtx.Unlock() - - var bloat_counter int - getconfig("bloat_counter", &bloat_counter) - - if bloat_counter < 9001 { - bloat_counter++ - saveconfig("bloat_counter", bloat_counter) - } - // 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th 11th 12th 13th - suf := "th" - switch bloat_counter % 10 { - case 1: - suf = "st" - case 2: - suf = "nd" - case 3: - suf = "rd" - } - if bloat_counter == 11 || bloat_counter == 12 || bloat_counter == 13 { - suf = "th" - } - val := fmt.Sprintf("%d%s", bloat_counter, suf) - log.Printf("now producing %s counter", val) - s = strings.Replace(s, "<bloat_counter>", val, -1) - return s -} - -func bloat_counterfixhonk(honk *Honk) { - honk.Noise = bloat_counterplusone(honk.Noise) -} - -func bloat_counterhtml(honk *Honk) { - honk.Noise = strings.Replace(honk.Noise, "<bloat_counter>", "1st", -1) -} - -func bloat_counterannounce(user *WhatAbout, honk *Honk) { - rcpts := make(map[string]bool) - for _, a := range honk.Audience { - if a != thewholeworld && a != user.URL && !strings.HasSuffix(a, "/followers") { - box, _ := getboxes(a) - if box != nil && honk.Public && box.Shared != "" { - rcpts["%"+box.Shared] = true - } else { - rcpts[a] = true - } - } - } - if honk.Public { - for _, f := range getdubs(user.ID) { - box, _ := getboxes(f.XID) - if box != nil && box.Shared != "" { - rcpts["%"+box.Shared] = true - } else { - rcpts[f.XID] = true - } - } - } - orignoise := honk.Noise - for a := range rcpts { - honk.Noise = orignoise - bloat_counterfixhonk(honk) - jonk, _ := jonkjonk(user, honk) - jonk["@context"] = itiswhatitis - var buf bytes.Buffer - jonk.Write(&buf) - msg := buf.Bytes() - go deliverate(0, user.Name, a, msg) - } -} - -func bloat_iscounter(honk *Honk) bool { - return strings.Contains(honk.Noise, "<bloat_counter>") -} - -func bloat_undocounter() { - db := opendatabase() - db.Exec("update honks set noise = 'This post has expired' where noise like '%<bloat_counter>%' and whofore = 2 and what = 'honk'") -}
M
honk.go
→
honk.go
@@ -510,9 +510,6 @@ honks := gethonksbyuser(name, false)
var jonks []junk.Junk for _, h := range honks { - if bloat_iscounter(h) { - continue - } j, _ := jonkjonk(user, h) jonks = append(jonks, j) }@@ -631,9 +628,6 @@ return
} if friendorfoe(r.Header.Get("Accept")) { donksforhonks([]*Honk{h}) - if bloat_iscounter(h) { - bloat_counterfixhonk(h) - } _, j := jonkjonk(user, h) j["@context"] = itiswhatitis w.Header().Set("Content-Type", theonetruename)@@ -1155,11 +1149,7 @@ return
} } - if bloat_iscounter(&honk) { - go bloat_counterannounce(user, &honk) - } else { - go honkworldwide(user, &honk) - } + go honkworldwide(user, &honk) http.Redirect(w, r, xid, http.StatusSeeOther) }@@ -1649,7 +1639,6 @@ stmtRecentHonkers = preparetodie(db, "select distinct(honker) from honks where userid = ? and honker not in (select xid from honkers where userid = ? and flavor = 'sub') order by honkid desc limit 100")
} func ElaborateUnitTests() { - bloat_undocounter() } func main() {