diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2020-08-24 13:58:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-24 13:58:56 -0400 |
commit | cbd8d83da7d24d7434c749c4c6cfece0c507b0b9 (patch) | |
tree | 51ed2f01e982ce7fab5b8b9f86279bbe3f19cea7 /synapse/rest/client/v2_alpha/relations.py | |
parent | Allow capping a room's retention policy (#8104) (diff) | |
download | synapse-cbd8d83da7d24d7434c749c4c6cfece0c507b0b9.tar.xz |
Stop shadow-banned users from sending non-member events. (#8142)
Diffstat (limited to 'synapse/rest/client/v2_alpha/relations.py')
-rw-r--r-- | synapse/rest/client/v2_alpha/relations.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/synapse/rest/client/v2_alpha/relations.py b/synapse/rest/client/v2_alpha/relations.py index 89002ffbff..e29f49f7f5 100644 --- a/synapse/rest/client/v2_alpha/relations.py +++ b/synapse/rest/client/v2_alpha/relations.py @@ -22,7 +22,7 @@ any time to reflect changes in the MSC. import logging from synapse.api.constants import EventTypes, RelationTypes -from synapse.api.errors import SynapseError +from synapse.api.errors import ShadowBanError, SynapseError from synapse.http.servlet import ( RestServlet, parse_integer, @@ -35,6 +35,7 @@ from synapse.storage.relations import ( PaginationChunk, RelationPaginationToken, ) +from synapse.util.stringutils import random_string from ._base import client_patterns @@ -111,11 +112,18 @@ class RelationSendServlet(RestServlet): "sender": requester.user.to_string(), } - event, _ = await self.event_creation_handler.create_and_send_nonmember_event( - requester, event_dict=event_dict, txn_id=txn_id - ) + try: + ( + event, + _, + ) = await self.event_creation_handler.create_and_send_nonmember_event( + requester, event_dict=event_dict, txn_id=txn_id + ) + event_id = event.event_id + except ShadowBanError: + event_id = "$" + random_string(43) - return 200, {"event_id": event.event_id} + return 200, {"event_id": event_id} class RelationPaginationServlet(RestServlet): |