From 40b0c36d21b53485fbb4290d3128f6644f74fac5 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Mon, 18 Jan 2021 14:55:38 +0000 Subject: [PATCH] minor: Update comment for guest subscription access. As my comment indicates, I would prefer to handle this explicitly by raising JsonableError in an else statement here, but it's not a big deal. This function can probably be simplified with a bit of work, mostly on the testing side to make sure we are covering all edge cases, but that is out of the scope of my current PR. --- zerver/lib/actions.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 93c5b9fc6b..31cc0bf5f2 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -2670,9 +2670,10 @@ def validate_user_access_to_subscribers_helper( if user_profile.is_guest: if check_user_subscribed(user_profile): return - # We could put an AssertionError here; in that we don't have - # any code paths that would allow a guest user to access other - # streams in the first place. + # We could explicitly handle the case where guests aren't + # subscribed here in an `else` statement or we can fall + # through to the subsequent logic. Tim prefers the latter. + # Adding an `else` would ensure better code coverage. if not user_profile.can_access_public_streams() and not stream_dict["invite_only"]: raise JsonableError(_("Subscriber data is not available for this stream"))