Finish implementing RM endpoint

- This change causes a 405 to be sent if "m.read_marker" is set via /account_data
 - This also fixes-up the RM endpoint so that it actually Works.
This commit is contained in:
Luke Barnard 2017-04-11 15:01:39 +01:00
parent e263c26690
commit d892079844
5 changed files with 65 additions and 46 deletions

View file

@ -16,7 +16,7 @@
from ._base import client_v2_patterns
from synapse.http.servlet import RestServlet, parse_json_object_from_request
from synapse.api.errors import AuthError
from synapse.api.errors import AuthError, SynapseError
from twisted.internet import defer
@ -82,6 +82,12 @@ class RoomAccountDataServlet(RestServlet):
body = parse_json_object_from_request(request)
if account_data_type == "m.read_marker":
raise SynapseError(405,
"Cannot set m.read_marker through this API. "
"Use /rooms/!roomId:server.name/read_marker"
)
max_id = yield self.store.add_account_data_to_room(
user_id, room_id, account_data_type, body
)