|
@@ -13,8 +13,6 @@
|
|
# See the License for the specific language governing permissions and
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
# limitations under the License.
|
|
|
|
|
|
-from six import integer_types, string_types
|
|
|
|
-
|
|
|
|
from synapse.api.constants import MAX_ALIAS_LENGTH, EventTypes, Membership
|
|
from synapse.api.constants import MAX_ALIAS_LENGTH, EventTypes, Membership
|
|
from synapse.api.errors import Codes, SynapseError
|
|
from synapse.api.errors import Codes, SynapseError
|
|
from synapse.api.room_versions import EventFormatVersions
|
|
from synapse.api.room_versions import EventFormatVersions
|
|
@@ -53,7 +51,7 @@ class EventValidator(object):
|
|
event_strings = ["origin"]
|
|
event_strings = ["origin"]
|
|
|
|
|
|
for s in event_strings:
|
|
for s in event_strings:
|
|
- if not isinstance(getattr(event, s), string_types):
|
|
|
|
|
|
+ if not isinstance(getattr(event, s), str):
|
|
raise SynapseError(400, "'%s' not a string type" % (s,))
|
|
raise SynapseError(400, "'%s' not a string type" % (s,))
|
|
|
|
|
|
# Depending on the room version, ensure the data is spec compliant JSON.
|
|
# Depending on the room version, ensure the data is spec compliant JSON.
|
|
@@ -90,7 +88,7 @@ class EventValidator(object):
|
|
max_lifetime = event.content.get("max_lifetime")
|
|
max_lifetime = event.content.get("max_lifetime")
|
|
|
|
|
|
if min_lifetime is not None:
|
|
if min_lifetime is not None:
|
|
- if not isinstance(min_lifetime, integer_types):
|
|
|
|
|
|
+ if not isinstance(min_lifetime, int):
|
|
raise SynapseError(
|
|
raise SynapseError(
|
|
code=400,
|
|
code=400,
|
|
msg="'min_lifetime' must be an integer",
|
|
msg="'min_lifetime' must be an integer",
|
|
@@ -124,7 +122,7 @@ class EventValidator(object):
|
|
)
|
|
)
|
|
|
|
|
|
if max_lifetime is not None:
|
|
if max_lifetime is not None:
|
|
- if not isinstance(max_lifetime, integer_types):
|
|
|
|
|
|
+ if not isinstance(max_lifetime, int):
|
|
raise SynapseError(
|
|
raise SynapseError(
|
|
code=400,
|
|
code=400,
|
|
msg="'max_lifetime' must be an integer",
|
|
msg="'max_lifetime' must be an integer",
|
|
@@ -183,7 +181,7 @@ class EventValidator(object):
|
|
strings.append("state_key")
|
|
strings.append("state_key")
|
|
|
|
|
|
for s in strings:
|
|
for s in strings:
|
|
- if not isinstance(getattr(event, s), string_types):
|
|
|
|
|
|
+ if not isinstance(getattr(event, s), str):
|
|
raise SynapseError(400, "Not '%s' a string type" % (s,))
|
|
raise SynapseError(400, "Not '%s' a string type" % (s,))
|
|
|
|
|
|
RoomID.from_string(event.room_id)
|
|
RoomID.from_string(event.room_id)
|
|
@@ -223,7 +221,7 @@ class EventValidator(object):
|
|
for s in keys:
|
|
for s in keys:
|
|
if s not in d:
|
|
if s not in d:
|
|
raise SynapseError(400, "'%s' not in content" % (s,))
|
|
raise SynapseError(400, "'%s' not in content" % (s,))
|
|
- if not isinstance(d[s], string_types):
|
|
|
|
|
|
+ if not isinstance(d[s], str):
|
|
raise SynapseError(400, "'%s' not a string type" % (s,))
|
|
raise SynapseError(400, "'%s' not a string type" % (s,))
|
|
|
|
|
|
def _ensure_state_event(self, event):
|
|
def _ensure_state_event(self, event):
|