diff options
author | Richard van der Hoff <github@rvanderhoff.org.uk> | 2017-09-19 12:20:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-19 12:20:11 +0100 |
commit | 5ed109d59f46c5185395f7c76050274fdd6abc15 (patch) | |
tree | ffc8f01e413fb140db66d63039aa20a26fcade58 /synapse/handlers | |
parent | Fix overzealous kicking of guest users (#2453) (diff) | |
download | synapse-5ed109d59f46c5185395f7c76050274fdd6abc15.tar.xz |
PoC for filtering spammy events (#2456)
Demonstration of how you might add some hooks to filter out spammy events.
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/message.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index be4f123c54..da18bf23db 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +from synapse.events import spamcheck from twisted.internet import defer from synapse.api.constants import EventTypes, Membership @@ -321,6 +321,12 @@ class MessageHandler(BaseHandler): token_id=requester.access_token_id, txn_id=txn_id ) + + if spamcheck.check_event_for_spam(event): + raise SynapseError( + 403, "Spam is not permitted here", Codes.FORBIDDEN + ) + yield self.send_nonmember_event( requester, event, |