mirror of
https://github.com/element-hq/synapse
synced 2024-09-04 14:50:06 +00:00
Allow clients to specify the format a room state event is returned in
This commit is contained in:
parent
685da5a3b0
commit
0fc0a3bdff
1 changed files with 7 additions and 1 deletions
|
@ -120,6 +120,8 @@ class RoomStateEventRestServlet(ClientV1RestServlet):
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def on_GET(self, request, room_id, event_type, state_key):
|
def on_GET(self, request, room_id, event_type, state_key):
|
||||||
requester = yield self.auth.get_user_by_req(request, allow_guest=True)
|
requester = yield self.auth.get_user_by_req(request, allow_guest=True)
|
||||||
|
format = parse_string(request, "format", default="content",
|
||||||
|
allowed_values=["content", "event"])
|
||||||
|
|
||||||
msg_handler = self.handlers.message_handler
|
msg_handler = self.handlers.message_handler
|
||||||
data = yield msg_handler.get_room_data(
|
data = yield msg_handler.get_room_data(
|
||||||
|
@ -134,7 +136,11 @@ class RoomStateEventRestServlet(ClientV1RestServlet):
|
||||||
raise SynapseError(
|
raise SynapseError(
|
||||||
404, "Event not found.", errcode=Codes.NOT_FOUND
|
404, "Event not found.", errcode=Codes.NOT_FOUND
|
||||||
)
|
)
|
||||||
defer.returnValue((200, data.get_dict()["content"]))
|
|
||||||
|
if format == "event":
|
||||||
|
defer.returnValue((200, data.get_dict()))
|
||||||
|
elif format == "content":
|
||||||
|
defer.returnValue((200, data.get_dict()["content"]))
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def on_PUT(self, request, room_id, event_type, state_key, txn_id=None):
|
def on_PUT(self, request, room_id, event_type, state_key, txn_id=None):
|
||||||
|
|
Loading…
Reference in a new issue