Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

actions: Move part into zerver.models.

Anders Kaseorg7f00aa078ee4
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index c92adbcdb76..b933c2c8442 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -260,6 +260,7 @@ from zerver.models import (
UserTopic,
active_non_guest_user_ids,
active_user_ids,
+ bot_owner_user_ids,
custom_profile_fields_for_realm,
filter_to_valid_prereg_users,
get_active_streams,
@@ -320,21 +321,6 @@ def subscriber_info(user_id: int) -> Dict[str, Any]:
return {"id": user_id, "flags": ["read"]}
-def bot_owner_user_ids(user_profile: UserProfile) -> Set[int]:
- is_private_bot = (
- user_profile.default_sending_stream
- and user_profile.default_sending_stream.invite_only
- or user_profile.default_events_register_stream
- and user_profile.default_events_register_stream.invite_only
- )
- if is_private_bot:
- return {user_profile.bot_owner_id}
- else:
- users = {user.id for user in user_profile.realm.get_human_admin_users()}
- users.add(user_profile.bot_owner_id)
- return users
-
-
def realm_user_count(realm: Realm) -> int:
return UserProfile.objects.filter(realm=realm, is_active=True, is_bot=False).count()
diff --git a/zerver/models.py b/zerver/models.py
index 16785ff9f39..c84c92675d0 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -3744,6 +3744,21 @@ def active_non_guest_user_ids(realm_id: int) -> List[int]:
return list(query)
+def bot_owner_user_ids(user_profile: UserProfile) -> Set[int]:
+ is_private_bot = (
+ user_profile.default_sending_stream
+ and user_profile.default_sending_stream.invite_only
+ or user_profile.default_events_register_stream
+ and user_profile.default_events_register_stream.invite_only
+ )
+ if is_private_bot:
+ return {user_profile.bot_owner_id}
+ else:
+ users = {user.id for user in user_profile.realm.get_human_admin_users()}
+ users.add(user_profile.bot_owner_id)
+ return users
+
+
def get_source_profile(email: str, realm_id: int) -> Optional[UserProfile]:
try:
return get_user_by_delivery_email(email, get_realm_by_id(realm_id))