delete all the bloat
This commit is contained in:
parent
0192c82046
commit
42931c4e10
92
bloat.go
92
bloat.go
|
@ -14,95 +14,3 @@
|
|||
// 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'")
|
||||
}
|
||||
|
|
3
fun.go
3
fun.go
|
@ -48,9 +48,6 @@ func reverbolate(userid int64, honks []*Honk) {
|
|||
h.URL = h.XID
|
||||
if h.What != "bonked" {
|
||||
h.Noise = mentionize(h.Noise)
|
||||
if bloat_iscounter(h) {
|
||||
bloat_counterhtml(h)
|
||||
}
|
||||
}
|
||||
h.Username, h.Handle = handles(h.Honker)
|
||||
} else {
|
||||
|
|
13
honk.go
13
honk.go
|
@ -510,9 +510,6 @@ func outbox(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
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 @@ func showhonk(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
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 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ func prepareStatements(db *sql.DB) {
|
|||
}
|
||||
|
||||
func ElaborateUnitTests() {
|
||||
bloat_undocounter()
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
Loading…
Reference in New Issue