Atlas
Atlas copied to clipboard
Implement bad words filter
Required for feature parity with the old server, also supersedes R2Northstar/NorthstarMasterServer#66.
If someone wants to work on this:
- First commit:
- Create a new package
pkg/badwordswhich containsbadwords.gowith atype List structand at least the functionsfunc ReadList(r io.Reader) (*List, error),func (l *List) AddWord(word string)(but don't need this if you're doing an optimized implementation which needs stuff to be precomputed) andfunc (l *List) Filter(s string) string. - It's up to you how to do the filtering, and while it should be efficient, it doesn't have to be optimal since we don't do it too often.
- Adding a word doesn't need to be safe for concurrent use.
- Create unit tests in
badwords_test.go.
- Create a new package
- Second commit:
- Add a config option in
pkg/atlas,BadWordList string `env:"ATLAS_BADWORDS_LIST"`. - Read the word list from the provided filename and set the
BadWordsfield ofapi0.Handlerwhen creating a new*Server.
- Add a config option in