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.

email_notifications: Use .exists() instead of .count() for realm check.

Tim Abbott58994c354770
diff --git a/zerver/lib/email_notifications.py b/zerver/lib/email_notifications.py
index 3dd87d9d7fe..9533031b807 100644
--- a/zerver/lib/email_notifications.py
+++ b/zerver/lib/email_notifications.py
@@ -405,13 +405,16 @@ def include_realm_name_in_missedmessage_emails_subject(user_profile: UserProfile
user_profile.realm_name_in_email_notifications_policy
== UserProfile.REALM_NAME_IN_EMAIL_NOTIFICATIONS_POLICY_AUTOMATIC
):
- realms_count = UserProfile.objects.filter(
- delivery_email=user_profile.delivery_email,
- is_active=True,
- is_bot=False,
- realm__deactivated=False,
- ).count()
- return realms_count > 1
+ return (
+ UserProfile.objects.filter(
+ delivery_email=user_profile.delivery_email,
+ is_active=True,
+ is_bot=False,
+ realm__deactivated=False,
+ )
+ .exclude(id=user_profile.id)
+ .exists()
+ )
return (
user_profile.realm_name_in_email_notifications_policy
== UserProfile.REALM_NAME_IN_EMAIL_NOTIFICATIONS_POLICY_ALWAYS