notification bot: Refactor send_pm_if_empty_stream to simplify logic.

This commit is contained in:
Rishi Gupta 2019-07-10 16:01:37 -07:00 committed by Tim Abbott
parent 9bace3f2cd
commit b92f936dad
1 changed files with 2 additions and 6 deletions

View File

@ -2120,15 +2120,11 @@ def send_pm_if_empty_stream(sender: UserProfile,
if not sender.is_bot or sender.bot_owner is None:
return
if stream is not None:
num_subscribers = num_subscribers_for_stream_id(stream.id)
if num_subscribers > 0:
return
if stream is None:
error_msg = "that stream does not yet exist. To create it, "
else:
# num_subscribers == 0
if num_subscribers_for_stream_id(stream.id) > 0:
return
error_msg = "there are no subscribers to that stream. To join it, "
if stream_id is not None: