diff options
author | Erik Johnston <erik@matrix.org> | 2019-01-29 10:34:49 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-01-29 10:34:49 +0000 |
commit | 28efc8072395e84cc747425bf8ee6c5b4401b55d (patch) | |
tree | 9884921ef4f35e4a291b9a7a3ac6a2bbc4cf7647 /synapse/events/validator.py | |
parent | Newsfile (diff) | |
download | synapse-28efc8072395e84cc747425bf8ee6c5b4401b55d.tar.xz |
Fold validate into validate_new
Diffstat (limited to '')
-rw-r--r-- | synapse/events/validator.py | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/synapse/events/validator.py b/synapse/events/validator.py index 55d44d093d..5c799493fb 100644 --- a/synapse/events/validator.py +++ b/synapse/events/validator.py @@ -21,8 +21,14 @@ from synapse.types import EventID, RoomID, UserID class EventValidator(object): + def validate_new(self, event): + """Validates the event has roughly the right format + + Args: + event (FrozenEvent) + """ + self.validate_builder(event) - def validate(self, event): EventID.from_string(event.event_id) required = [ @@ -40,32 +46,21 @@ class EventValidator(object): raise SynapseError(400, "Event does not have key %s" % (k,)) # Check that the following keys have string values - strings = [ + event_strings = [ "origin", ] - for s in strings: + for s in event_strings: if not isinstance(getattr(event, s), string_types): raise SynapseError(400, "Not '%s' a string type" % (s,)) - def validate_new(self, event): - """Validates the event has roughly the right format - - Args: - event (FrozenEvent) - """ - self.validate_builder(event) - self.validate(event) - - UserID.from_string(event.sender) - if event.type == EventTypes.Message: - strings = [ + content_strings = [ "body", "msgtype", ] - self._ensure_strings(event.content, strings) + self._ensure_strings(event.content, content_strings) elif event.type == EventTypes.Topic: self._ensure_strings(event.content, ["topic"]) |