# HG changeset patch # User Ted Unangst # Date 1718503647 14400 # Sat Jun 15 22:07:27 2024 -0400 # Node ID 4095e69c5fbcad1c1475f2dd18b8501044a0e33d # Parent 115d565f3b3e891b04b705445a04ad7a3f7b2605 use const instead of magic numbers diff --git a/activity.go b/activity.go --- a/activity.go +++ b/activity.go @@ -427,7 +427,7 @@ dlog.Printf("error getting boxes for %s: %s", ident, err) str := err.Error() if strings.Contains(str, "http get status: 410") || - strings.Contains(str, "http get status: 404") { + strings.Contains(str, "http get status: 404") { savexonker(ident, "dead", "boxes") } return nil, true @@ -1245,14 +1245,14 @@ xonk.Mentions = mentions if myown { if xonk.Public { - xonk.Whofore = 2 + xonk.Whofore = WhoPublic } else { - xonk.Whofore = 3 + xonk.Whofore = WhoPrivate } } else { for _, m := range mentions { if m.Where == user.URL { - xonk.Whofore = 1 + xonk.Whofore = WhoAtme } } } @@ -1638,7 +1638,7 @@ rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy, 0) reversehonks(rawhonks) for _, h := range rawhonks { - if h.RID == honk.XID && h.Public && (h.Whofore == 2 || h.IsAcked()) { + if h.RID == honk.XID && h.Public && (h.Whofore == WhoPublic || h.IsAcked()) { honk.Replies = append(honk.Replies, h) } } diff --git a/database.go b/database.go --- a/database.go +++ b/database.go @@ -773,7 +773,7 @@ err = saveextras(tx, h) } if err == nil { - if h.Whofore == 1 { + if h.Whofore == WhoAtme { dlog.Printf("another one for me: %s", h.XID) meplusone(tx, h.UserID) } diff --git a/fun.go b/fun.go --- a/fun.go +++ b/fun.go @@ -78,12 +78,12 @@ if !h.Public { h.Style += " limited" } - if h.Whofore == 1 { + if h.Whofore == WhoAtme { h.Style += " atme" } translate(h) local := false - if h.Whofore == 2 || h.Whofore == 3 { + if h.Whofore == WhoPublic || h.Whofore == WhoPrivate { local = true } if local && h.What != "bonked" { diff --git a/honk.go b/honk.go --- a/honk.go +++ b/honk.go @@ -85,7 +85,7 @@ Convoy string Audience []string Public bool - Whofore int64 + Whofore Whofore Replies []*Honk Flags int64 HTPrecis template.HTML @@ -104,6 +104,12 @@ LegalName string } +type Whofore int + +const WhoAtme Whofore = 1 +const WhoPublic Whofore = 2 +const WhoPrivate Whofore = 3 + type Badonk struct { Who string What string diff --git a/import.go b/import.go --- a/import.go +++ b/import.go @@ -195,12 +195,12 @@ Audience: audience, Noise: content, Convoy: convoy, - Whofore: 2, + Whofore: WhoPublic, Format: format, Precis: toot.Object.Summary, } if !loudandproud(honk.Audience) { - honk.Whofore = 3 + honk.Whofore = WhoPrivate } for _, att := range toot.Object.Attachment { var meta DonkMeta @@ -450,7 +450,7 @@ Audience: audience, Convoy: t.convoy, Public: true, - Whofore: 2, + Whofore: WhoPublic, } noise += t.Tweet.FullText // unbelievable @@ -539,7 +539,7 @@ Audience: audience, Convoy: convoy, Public: true, - Whofore: 2, + Whofore: WhoPublic, } { var meta DonkMeta @@ -757,12 +757,12 @@ Audience: audience, Noise: content, Convoy: convoy, - Whofore: 2, + Whofore: WhoPublic, Format: format, Precis: toot.Object.Summary, } if !loudandproud(honk.Audience) { - honk.Whofore = 3 + honk.Whofore = WhoPrivate } for _, t := range toot.Object.Tag { switch t.Type { diff --git a/web.go b/web.go --- a/web.go +++ b/web.go @@ -1498,7 +1498,7 @@ h.Style += " glow" } } - if h.Public && (h.Whofore == 2 || h.IsAcked()) { + if h.Public && (h.Whofore == WhoPublic || h.IsAcked()) { honks = append(honks, h) } } @@ -1648,7 +1648,7 @@ URL: xonk.URL, Date: dt, Donks: xonk.Donks, - Whofore: 2, + Whofore: WhoPublic, Convoy: xonk.Convoy, Audience: []string{thewholeworld, oonker}, Public: true, @@ -1812,7 +1812,7 @@ xonk := getxonk(user.ID, what) if xonk != nil { deletehonk(xonk.ID) - if xonk.Whofore == 2 || xonk.Whofore == 3 { + if xonk.Whofore == WhoPublic || xonk.Whofore == WhoPrivate { sendzonkofsorts(xonk, user, "zonk", "") } } @@ -2204,9 +2204,9 @@ } if honk.Public { - honk.Whofore = 2 + honk.Whofore = WhoPublic } else { - honk.Whofore = 3 + honk.Whofore = WhoPrivate } // back to markdown