commit b02dfcadbdb4afcf42151bcbc1cdfb8599ab4358
parent ad60c48ff27ed659e75113d1cbe8c0bb76868489
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 12 Jan 2023 14:15:09 -0800
remove hardcoded values
Diffstat:
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/pkg/template/templates.go b/pkg/template/templates.go
@@ -49,6 +49,7 @@ type templateDataStruct struct {
VersionHTML template.HTML
ShaHTML template.HTML
LogoASCII template.HTML
+ NullUsername string
CSRF string
Master bool
Development bool
@@ -74,6 +75,7 @@ func (t *Templates) Render(w io.Writer, name string, data any, c echo.Context) e
//d.SHA = config.Global.Sha()
d.VersionHTML = template.HTML(fmt.Sprintf("<!-- VERSION: %s -->", config.Global.GetVersion().Original()))
d.ShaHTML = template.HTML(fmt.Sprintf("<!-- SHA: %s -->", config.Global.Sha()))
+ d.NullUsername = config.NullUsername
d.CSRF = c.Get("csrf").(string)
d.AcceptLanguage = c.Get("accept-language").(string)
d.Lang = c.Get("lang").(string)
diff --git a/pkg/web/handlers/api/v1/topBarHandler.go b/pkg/web/handlers/api/v1/topBarHandler.go
@@ -649,7 +649,7 @@ func colorifyTaggedUsers(html string, getUsersByUsername getUsersByUsernameFn) (
taggedUsersIDsMap := make(map[database.UserID]database.User)
for _, taggedUser := range taggedUsers {
taggedUsersMap["@"+taggedUser.Username] = taggedUser
- if taggedUser.Username != "0" {
+ if taggedUser.Username != config.NullUsername {
taggedUsersIDsMap[taggedUser.ID] = taggedUser
}
}
diff --git a/pkg/web/public/views/pages/chat-messages.gohtml b/pkg/web/public/views/pages/chat-messages.gohtml
@@ -206,7 +206,7 @@
{{ if $.AuthUser.IsModerator }}
{{ if ne .UserID $.AuthUser.ID }}
{{- if $.AuthUser.DisplayHellbanButton -}}
- {{- if eq .User.Username "0" -}}
+ {{- if eq .User.Username $.NullUsername -}}
<div style="display: inline-block; width: 16px;"></div>
{{- else -}}
<form method="post" action="/api/v1/users/{{ .UserID }}/toggle-hellban" style="display: inline;">