mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 12:03:46 +00:00 
			
		
		
		
	streams: Grant guest users access to web-public streams.
In this commit, we grant guest users access to stream history, send message and common stream data of web-public streams. This is part of PR #14638 that aims to allow guest users to browse and subscribe to web-public streams.
This commit is contained in:
		| @@ -163,6 +163,10 @@ def access_stream_for_send_message(sender: UserProfile, | ||||
|         elif sender.is_new_member: | ||||
|             raise JsonableError(_("New members cannot send to this stream.")) | ||||
|  | ||||
|     if stream.is_web_public: | ||||
|         # Even guest users can write to web-public streams. | ||||
|         return | ||||
|  | ||||
|     if not (stream.invite_only or sender.is_guest): | ||||
|         # This is a public stream and sender is not a guest user | ||||
|         return | ||||
| @@ -242,6 +246,10 @@ def access_stream_common(user_profile: UserProfile, stream: Stream, | ||||
|     except Subscription.DoesNotExist: | ||||
|         sub = None | ||||
|  | ||||
|     # Any realm user, even guests, can access web_public streams. | ||||
|     if stream.is_web_public: | ||||
|         return (recipient, sub) | ||||
|  | ||||
|     # If the stream is in your realm and public, you can access it. | ||||
|     if stream.is_public() and not user_profile.is_guest: | ||||
|         return (recipient, sub) | ||||
| @@ -353,6 +361,9 @@ def can_access_stream_history(user_profile: UserProfile, stream: Stream) -> bool | ||||
|     access_stream is being called elsewhere to confirm that the user | ||||
|     can actually see this stream. | ||||
|     """ | ||||
|     if stream.is_web_public: | ||||
|         return True | ||||
|  | ||||
|     if stream.is_history_realm_public() and not user_profile.is_guest: | ||||
|         return True | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user