mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +00:00
Disable public streams for a CUSTOMER5 contractor.
(imported from commit bb7997cd831b9df9c951e3ecefe8a65b06bf6732)
This commit is contained in:
@@ -158,6 +158,10 @@ class UserProfile(AbstractBaseUser, PermissionsMixin):
|
|||||||
content_type__name="realm",
|
content_type__name="realm",
|
||||||
permission__codename="administer").count()
|
permission__codename="administer").count()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def public_streams_disabled(self):
|
||||||
|
return self.email.lower() == "restricted-user@customer5.invalid"
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return (u"<UserProfile: %s %s>" % (self.email, self.realm)).encode("utf-8")
|
return (u"<UserProfile: %s %s>" % (self.email, self.realm)).encode("utf-8")
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
@@ -1303,8 +1303,10 @@ def get_streams_backend(request, user_profile,
|
|||||||
if include_all_active and not is_super_user_api(request):
|
if include_all_active and not is_super_user_api(request):
|
||||||
return json_error("User not authorized for this query")
|
return json_error("User not authorized for this query")
|
||||||
|
|
||||||
# Listing public streams are disabled for the mit.edu realm.
|
# Listing public streams are disabled for some users (e.g. a
|
||||||
include_public = include_public and not user_profile.realm.domain == "mit.edu"
|
# contractor for CUSTOMER5) and for the mit.edu realm.
|
||||||
|
include_public = include_public and not (user_profile.public_streams_disabled or
|
||||||
|
user_profile.realm.domain == "mit.edu")
|
||||||
|
|
||||||
# Only get streams someone is currently subscribed to
|
# Only get streams someone is currently subscribed to
|
||||||
subs_filter = Subscription.objects.filter(active=True).values('recipient_id')
|
subs_filter = Subscription.objects.filter(active=True).values('recipient_id')
|
||||||
@@ -1413,8 +1415,15 @@ def filter_stream_authorization(user_profile, streams):
|
|||||||
|
|
||||||
unauthorized_streams = []
|
unauthorized_streams = []
|
||||||
for stream in streams:
|
for stream in streams:
|
||||||
if stream.invite_only and not stream.id in streams_subscribed:
|
# The user is authorized for his own streams
|
||||||
|
if stream.id in streams_subscribed:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# The user is not authorized for invite_only streams, and if
|
||||||
|
# the user has public streams disabled, nothing is authorized
|
||||||
|
if stream.invite_only or user_profile.public_streams_disabled:
|
||||||
unauthorized_streams.append(stream)
|
unauthorized_streams.append(stream)
|
||||||
|
|
||||||
streams = [stream for stream in streams if
|
streams = [stream for stream in streams if
|
||||||
stream.id not in set(stream.id for stream in unauthorized_streams)]
|
stream.id not in set(stream.id for stream in unauthorized_streams)]
|
||||||
return streams, unauthorized_streams
|
return streams, unauthorized_streams
|
||||||
|
|||||||
Reference in New Issue
Block a user