internal_prep_message: Don't call ensure_stream for stream IDs.

Ever since we implemented support for stream IDs in Addressee,
Addressee.stream_name() can now return None. This commit ensures
that _internal_prep_message only calls ensure_stream when
Addressee.stream_name() is not None.
This commit is contained in:
Eeshan Garg
2019-01-30 00:26:53 -03:30
committed by Tim Abbott
parent 0420ecadeb
commit f4221f2655

View File

@@ -2280,7 +2280,12 @@ def _internal_prep_message(realm: Realm,
if realm is None:
raise RuntimeError("None is not a valid realm for internal_prep_message!")
if addressee.is_stream():
# If we have a stream name, and the stream doesn't exist, we
# create it here (though this code path should probably be removed
# eventually, moving that responsibility to the caller). If
# addressee.stream_name() is None (i.e. we're sending to a stream
# by ID), we skip this, as the stream object must already exist.
if addressee.is_stream() and addressee.stream_name() is not None:
ensure_stream(realm, addressee.stream_name())
try: