4095e69c5fbc — Ted Unangst 6 months ago
use const instead of magic numbers
6 files changed, 26 insertions(+), 20 deletions(-)

M activity.go
M database.go
M fun.go
M honk.go
M import.go
M web.go
M activity.go +5 -5
@@ 427,7 427,7 @@ var boxofboxes = gencache.New(gencache.O
 			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 @@ func xonksaver2(user *WhatAbout, item ju
 		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 @@ var oldjonks = gencache.New(gencache.Opt
 	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)
 		}
 	}

          
M database.go +1 -1
@@ 773,7 773,7 @@ func savehonk(h *Honk) error {
 		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)
 		}

          
M fun.go +2 -2
@@ 78,12 78,12 @@ func reverbolate(userid UserID, honks []
 		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" {

          
M honk.go +7 -1
@@ 85,7 85,7 @@ type Honk struct {
 	Convoy    string
 	Audience  []string
 	Public    bool
-	Whofore   int64
+	Whofore   Whofore
 	Replies   []*Honk
 	Flags     int64
 	HTPrecis  template.HTML

          
@@ 104,6 104,12 @@ type Honk struct {
 	LegalName string
 }
 
+type Whofore int
+
+const WhoAtme Whofore = 1
+const WhoPublic Whofore = 2
+const WhoPrivate Whofore = 3
+
 type Badonk struct {
 	Who  string
 	What string

          
M import.go +6 -6
@@ 195,12 195,12 @@ func importActivities(user *WhatAbout, f
 			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 @@ func importTwitter(username, source stri
 			Audience: audience,
 			Convoy:   t.convoy,
 			Public:   true,
-			Whofore:  2,
+			Whofore:  WhoPublic,
 		}
 		noise += t.Tweet.FullText
 		// unbelievable

          
@@ 539,7 539,7 @@ func importInstagram(username, source st
 			Audience: audience,
 			Convoy:   convoy,
 			Public:   true,
-			Whofore:  2,
+			Whofore:  WhoPublic,
 		}
 		{
 			var meta DonkMeta

          
@@ 757,12 757,12 @@ func rawimport(username, filename string
 			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 {

          
M web.go +5 -5
@@ 1498,7 1498,7 @@ func showonehonk(w http.ResponseWriter, 
 				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 @@ func bonkit(xid string, user *WhatAbout)
 		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 @@ func zonkit(w http.ResponseWriter, r *ht
 		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 @@ func submithonk(w http.ResponseWriter, r
 	}
 
 	if honk.Public {
-		honk.Whofore = 2
+		honk.Whofore = WhoPublic
 	} else {
-		honk.Whofore = 3
+		honk.Whofore = WhoPrivate
 	}
 
 	// back to markdown