This template shows how to perform server side moderation of text written to a Firebase DB.
For instance if a user added the message "I DON'T LIKE THIS APP!! This is POOP!!!" this will get moderated to a - more civilized - non uppercase message: "I don't like this app. This is ****".
Moderation of the messages is performed using [bad-words](https://www.npmjs.com/package/bad-words) a bad words remover that uses an external [list of bad-words](https://github.com/web-mech/badwords-list) and is currently mostly aimed at filtering english bad words. Also messages that contains mostly upper case characters are re-capitalized correctly using [capitalize-sentence](https://www.npmjs.com/package/capitalize-sentence).
Once the function has ran on the newly added messages it adds two attributes. `sanitized` which is `true` if message has been looked at and `moderated` which is `true` if it was detected that the message contained offensive content and was modified:
The security rules only allow users to create message but not edit them afterwards. Also it does not allows users to set the `sanitized` value. Only the Functions is allowed to modify `sanitized` by using an admin authorized reference.