mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
Replace settings.OG_ZULIPER_EMAILS with database lookups
Also renames the OG_ZULIPER_EMAILS to CROSS_REALM_BOT_EMAILS (imported from commit a9e0ccebbd6b37376e535600670ad493dc8de7e1)
This commit is contained in:
@@ -597,7 +597,12 @@ def recipient_for_emails(emails, not_forged_mirror_message,
|
||||
|
||||
# Prevent cross realm private messages unless it is between only two realms
|
||||
# and one of users is a zuliper
|
||||
if len(realm_domains) == 2 and not (normalized_emails & settings.OG_ZULIPER_EMAILS):
|
||||
if len(realm_domains) == 2:
|
||||
# I'm assuming that cross-realm PMs with the "admin realm" are rare, and therefore can be slower
|
||||
admin_realm = Realm.objects.get(domain=settings.ADMIN_DOMAIN)
|
||||
admin_realm_admin_emails = [u.email for u in admin_realm.get_admin_users()]
|
||||
# We allow settings.CROSS_REALM_BOT_EMAILS for the hardcoded emails for the feedback and notification bots
|
||||
if not (normalized_emails & admin_realm_admin_emails or normalized_emails & settings.CROSS_REALM_BOT_EMAILS):
|
||||
raise ValidationError("You can't send private messages outside of your organization.")
|
||||
if len(realm_domains) > 2:
|
||||
raise ValidationError("You can't send private messages outside of your organization.")
|
||||
|
||||
@@ -157,7 +157,7 @@ class IncludeHistoryTest(AuthedTestCase):
|
||||
|
||||
class TestCrossRealmPMs(AuthedTestCase):
|
||||
def setUp(self):
|
||||
settings.OG_ZULIPER_EMAILS.add('test-og-user@zulip.com')
|
||||
settings.CROSS_REALM_BOT_EMAILS.add('test-og-bot@zulip.com')
|
||||
|
||||
def create_user(self, email):
|
||||
username, domain = email.split('@')
|
||||
@@ -225,7 +225,7 @@ class TestCrossRealmPMs(AuthedTestCase):
|
||||
deployment = Deployment.objects.filter()[0]
|
||||
deployment.realms.add(r1)
|
||||
|
||||
user1_email = 'test-og-user@zulip.com'
|
||||
user1_email = 'test-og-bot@zulip.com'
|
||||
user1 = self.create_user(user1_email)
|
||||
user2_email = 'user2@1.example.com'
|
||||
user2 = self.create_user(user2_email)
|
||||
@@ -244,7 +244,7 @@ class TestCrossRealmPMs(AuthedTestCase):
|
||||
|
||||
user1_email = 'user1@1.example.com'
|
||||
user1 = self.create_user(user1_email)
|
||||
user2_email = 'test-og-user@zulip.com'
|
||||
user2_email = 'test-og-bot@zulip.com'
|
||||
user2 = self.create_user(user2_email)
|
||||
|
||||
self.send_message(user1_email, user2_email, Recipient.PERSONAL)
|
||||
@@ -265,7 +265,7 @@ class TestCrossRealmPMs(AuthedTestCase):
|
||||
self.create_user(user1_email)
|
||||
user2_email = 'user2@2.example.com'
|
||||
self.create_user(user2_email)
|
||||
user3_email = 'test-og-user@zulip.com'
|
||||
user3_email = 'test-og-bot@zulip.com'
|
||||
self.create_user(user3_email)
|
||||
|
||||
with self.assertRaisesRegexp(JsonableError,
|
||||
|
||||
@@ -932,5 +932,4 @@ USING_EMBEDLY = False
|
||||
# This is a debugging option only
|
||||
PROFILE_ALL_REQUESTS = False
|
||||
|
||||
OG_ZULIPER_EMAILS = set(('feedback@zulip.com', 'notification-bot@zulip.com',
|
||||
))
|
||||
CROSS_REALM_BOT_EMAILS = set(('feedback@zulip.com', 'notification-bot@zulip.com'))
|
||||
|
||||
Reference in New Issue
Block a user