diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2021-07-21 09:47:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-21 09:47:56 -0400 |
commit | 5db118626bebb9ce3913758282787d47cd8f375e (patch) | |
tree | 9515e33f8e3a319f2e76ca88094654d946304979 /synapse/streams | |
parent | Switch to `chunk` events so we can auth via power_levels (MSC2716) (#10432) (diff) | |
download | synapse-5db118626bebb9ce3913758282787d47cd8f375e.tar.xz |
Add a return type to parse_string. (#10438)
And set the required attribute in a few places which will error if a parameter is not provided.
Diffstat (limited to '')
-rw-r--r-- | synapse/streams/config.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/synapse/streams/config.py b/synapse/streams/config.py index 13d300588b..cf4005984b 100644 --- a/synapse/streams/config.py +++ b/synapse/streams/config.py @@ -47,20 +47,22 @@ class PaginationConfig: ) -> "PaginationConfig": direction = parse_string(request, "dir", default="f", allowed_values=["f", "b"]) - from_tok = parse_string(request, "from") - to_tok = parse_string(request, "to") + from_tok_str = parse_string(request, "from") + to_tok_str = parse_string(request, "to") try: - if from_tok == "END": + from_tok = None + if from_tok_str == "END": from_tok = None # For backwards compat. - elif from_tok: - from_tok = await StreamToken.from_string(store, from_tok) + elif from_tok_str: + from_tok = await StreamToken.from_string(store, from_tok_str) except Exception: raise SynapseError(400, "'from' parameter is invalid") try: - if to_tok: - to_tok = await StreamToken.from_string(store, to_tok) + to_tok = None + if to_tok_str: + to_tok = await StreamToken.from_string(store, to_tok_str) except Exception: raise SynapseError(400, "'to' parameter is invalid") |