Assemble Remote speech before reader delivery
This commit is contained in:
1 parent
f23e89ed93
commit
205cb27483
9 files changed
+492
-33
No files matched your search
@@ -87,6 +87,21 @@ def valid_remote_speech(speech):
|
||||
return False
|
||||
|
||||
|
||||
def valid_remote_presentation(request):
|
||||
"""Validate one speech call; assembly and lease checks belong to core."""
|
||||
try:
|
||||
_fields(request, ("lease", "epoch", "sequence", "speech"), ("utterance", "final"))
|
||||
utterance, final = request.get("utterance", 0), request.get("final", False)
|
||||
return (_token(request["lease"]) and _positive(request["epoch"])
|
||||
and _positive(request["sequence"]) and valid_remote_speech(request["speech"])
|
||||
and type(utterance) is int and 0 <= utterance < 2**64
|
||||
and type(final) is bool
|
||||
and (utterance == 0 and not final
|
||||
or 0 < utterance <= request["sequence"] and request["speech"]["kind"] == "speak"))
|
||||
except (ProtocolError, TypeError, ValueError, UnicodeError):
|
||||
return False
|
||||
|
||||
|
||||
class SessionError(Exception):
|
||||
def __init__(self, code, message):
|
||||
super().__init__("Tentacle session error " + str(code))
|
||||
|
||||
Reference in new issue
Block a user