Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix buglet in DirectRenderJsonResource #8897

Merged
merged 2 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8897.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for allowing users to pick their own user ID during a single-sign-on login.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is part of a forthcoming feature, obviously.

8 changes: 5 additions & 3 deletions synapse/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ class DirectServeJsonResource(_AsyncResource):
formatting responses and errors as JSON.
"""

def __init__(self, canonical_json=False, extract_context=False):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've set the default for canonical_json to be False here, whereas it is True for JsonResource, simply because I think you want non-canonical-json more often than you want canonical-json. I don't really know why JsonResource makes the default True.

super().__init__(extract_context)
self.canonical_json = canonical_json

Comment on lines +278 to +281
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change means that the first positional param of the constructor is now canonical_json, whereas it was previously extract_context. I thought that keeping the consistency with JsonResource was the lesser evil. I did go through the codebase to check that nothing other than JsonResource was making a call which would be misinterpreted.

def _send_response(
self, request: Request, code: int, response_object: Any,
):
Expand Down Expand Up @@ -318,9 +322,7 @@ class JsonResource(DirectServeJsonResource):
)

def __init__(self, hs, canonical_json=True, extract_context=False):
super().__init__(extract_context)

self.canonical_json = canonical_json
super().__init__(canonical_json, extract_context)
self.clock = hs.get_clock()
self.path_regexs = {}
self.hs = hs
Expand Down