mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-07 11:42:11 -04:00
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.
This commit is contained in:
parent
2d89c66b88
commit
5db118626b
13 changed files with 86 additions and 45 deletions
|
@ -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")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue