continuation of PR #8074 Adding spam prevention - fixes #8060 (#8687)

* Adding code to look over the most recent messages to look for spam from a user

* Adding in translatable error message

* Adding 2 tests for spam detection

* Fixing changes requested for pull request

* Adding unit tests for group and fixing requested changes

* Fixing message and tests

* Forgot to remove this import

* Fixing lint errors

* Cleaning up the code and tests to be more readable

* Fixing lint errors

* Fixed linting issues

* Syntax fixes

* Updated grammar
This commit is contained in:
Keith Holliday
2017-04-26 13:37:18 -06:00
committed by GitHub
parent c9ee6c7f73
commit 6a99daebac
5 changed files with 174 additions and 3 deletions

View File

@@ -153,6 +153,10 @@ api.postChat = {
let lastClientMsg = req.query.previousMsg;
chatUpdated = lastClientMsg && group.chat && group.chat[0] && group.chat[0].id !== lastClientMsg ? true : false;
if (group.checkChatSpam(user)) {
throw new NotAuthorized(res.t('messageGroupChatSpam'));
}
let newChatMessage = group.sendChat(req.body.message, user);
let toSave = [group.save()];