streams: Use can_add_subscribers_group for permission check.

The function to check relevant permissions does so for multiple streams
at once to save us database query counts. Doing it one by one for every
stream would become very expensive.
We've also added `insufficient_permission_streams` to the filter
functions return type for streams for which the current user does not
have permission to subscribe other users.
This commit is contained in:
Shubham Padia
2025-01-16 21:17:29 +00:00
committed by Tim Abbott
parent 7df417f8b1
commit 41c74314c0
6 changed files with 339 additions and 34 deletions

View File

@@ -844,7 +844,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings):
def can_manage_default_streams(self) -> bool:
return self.is_realm_admin
def can_subscribe_other_users(self) -> bool:
def can_subscribe_others_to_all_streams(self) -> bool:
return self.has_permission("can_add_subscribers_group")
def can_invite_users_by_email(self, realm: Optional["Realm"] = None) -> bool: