translate known actors to shortnames
This commit is contained in:
parent
ebe7863e75
commit
878c3c28e9
29
fun.go
29
fun.go
|
@ -70,9 +70,14 @@ func reverbolate(userid int64, honks []*Honk) {
|
||||||
h.Username, h.Handle = handles(h.Honker)
|
h.Username, h.Handle = handles(h.Honker)
|
||||||
} else {
|
} else {
|
||||||
_, h.Handle = handles(h.Honker)
|
_, h.Handle = handles(h.Honker)
|
||||||
h.Username = h.Handle
|
short := shortname(userid, h.Honker)
|
||||||
if len(h.Username) > 20 {
|
if short != "" {
|
||||||
h.Username = h.Username[:20] + ".."
|
h.Username = short
|
||||||
|
} else {
|
||||||
|
h.Username = h.Handle
|
||||||
|
if len(h.Username) > 20 {
|
||||||
|
h.Username = h.Username[:20] + ".."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if h.URL == "" {
|
if h.URL == "" {
|
||||||
h.URL = h.XID
|
h.URL = h.XID
|
||||||
|
@ -360,6 +365,24 @@ func quickrename(s string, userid int64) string {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var shortnames = cacheNew(cacheOptions{Filler: func(userid int64) (map[string]string, bool) {
|
||||||
|
honkers := gethonkers(userid)
|
||||||
|
m := make(map[string]string)
|
||||||
|
for _, h := range honkers {
|
||||||
|
m[h.XID] = h.Name
|
||||||
|
}
|
||||||
|
return m, true
|
||||||
|
}})
|
||||||
|
|
||||||
|
func shortname(userid int64, xid string) string {
|
||||||
|
var m map[string]string
|
||||||
|
ok := shortnames.Get(userid, &m)
|
||||||
|
if ok {
|
||||||
|
return m[xid]
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func mentionize(s string) string {
|
func mentionize(s string) string {
|
||||||
s = re_mentions.ReplaceAllStringFunc(s, func(m string) string {
|
s = re_mentions.ReplaceAllStringFunc(s, func(m string) string {
|
||||||
where := gofish(m)
|
where := gofish(m)
|
||||||
|
|
1
web.go
1
web.go
|
@ -1271,6 +1271,7 @@ func submithonker(w http.ResponseWriter, r *http.Request) {
|
||||||
honkerid, _ := strconv.ParseInt(r.FormValue("honkerid"), 10, 0)
|
honkerid, _ := strconv.ParseInt(r.FormValue("honkerid"), 10, 0)
|
||||||
|
|
||||||
defer combocache.Clear(u.UserID)
|
defer combocache.Clear(u.UserID)
|
||||||
|
defer shortnames.Clear(u.UserID)
|
||||||
|
|
||||||
if honkerid > 0 {
|
if honkerid > 0 {
|
||||||
goodbye := r.FormValue("goodbye")
|
goodbye := r.FormValue("goodbye")
|
||||||
|
|
Loading…
Reference in New Issue