diff options
| author | pg9182 <96569817+pg9182@users.noreply.github.com> | 2022-10-15 10:49:28 -0400 |
|---|---|---|
| committer | pg9182 <96569817+pg9182@users.noreply.github.com> | 2022-10-15 10:49:28 -0400 |
| commit | 0b57063d451db15e30b5568bfa3e3c2d77de8a87 (patch) | |
| tree | 500c5c5bb4695fa848b12c6edeaa9426c88f5df7 /pkg/api/api0 | |
| parent | b4dc294dbe03210bd2cc0d69edc15a5e925f19c7 (diff) | |
| download | Atlas-0b57063d451db15e30b5568bfa3e3c2d77de8a87.tar.gz Atlas-0b57063d451db15e30b5568bfa3e3c2d77de8a87.zip | |
pkg/api/api0: Implement bad words filter option
Diffstat (limited to 'pkg/api/api0')
| -rw-r--r-- | pkg/api/api0/api.go | 4 | ||||
| -rw-r--r-- | pkg/api/api0/server.go | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/pkg/api/api0/api.go b/pkg/api/api0/api.go index 0786463..818f6b9 100644 --- a/pkg/api/api0/api.go +++ b/pkg/api/api0/api.go @@ -43,6 +43,10 @@ type Handler struct { // usernames). If not provided, usernames will not be updated. OriginAuthMgr *origin.AuthMgr + // CleanBadWords is used to filter bad words from server names and + // descriptions. If not provided, words will not be filtered. + CleanBadWords func(s string) string + // MainMenuPromos gets the main menu promos to return for a request. MainMenuPromos func(*http.Request) MainMenuPromos diff --git a/pkg/api/api0/server.go b/pkg/api/api0/server.go index bb25790..06f4957 100644 --- a/pkg/api/api0/server.go +++ b/pkg/api/api0/server.go @@ -194,7 +194,9 @@ func (h *Handler) handleServerUpsert(w http.ResponseWriter, r *http.Request) { return } } else { - // TODO: bad word censoring + if h.CleanBadWords != nil { + v = h.CleanBadWords(v) + } if n := 256; len(v) > n { // NorthstarLauncher@v1.9.7 limits it to 63 v = v[:n] } @@ -207,7 +209,9 @@ func (h *Handler) handleServerUpsert(w http.ResponseWriter, r *http.Request) { } if v := r.URL.Query().Get("description"); v != "" { - // TODO: bad word censoring + if h.CleanBadWords != nil { + v = h.CleanBadWords(v) + } if n := 1024; len(v) > n { // NorthstarLauncher@v1.9.7 doesn't have a limit v = v[:n] } |
