From 3aae6cd4213b43ee396d3b7ddad33b8997687233 Mon Sep 17 00:00:00 2001 From: Rishi Gupta Date: Mon, 13 Mar 2017 11:06:33 -0700 Subject: [PATCH] Change if(realm.domain == zulip.com) checks to use Realm.string_id. --- zerver/lib/export.py | 2 +- zerver/lib/notifications.py | 2 +- zerver/tests/test_upload.py | 2 +- zerver/views/upload.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zerver/lib/export.py b/zerver/lib/export.py index f0f0209fce..aa5432eaea 100644 --- a/zerver/lib/export.py +++ b/zerver/lib/export.py @@ -581,7 +581,7 @@ def fetch_user_profile_cross_realm(response, config, context): # type: (TableData, Config, Context) -> None realm = context['realm'] - if realm.domain == "zulip.com": + if realm.string_id == "zulip": response['zerver_userprofile_crossrealm'] = [] else: response['zerver_userprofile_crossrealm'] = [dict(email=x.email, id=x.id) for x in [ diff --git a/zerver/lib/notifications.py b/zerver/lib/notifications.py index 24f2df61b5..8371ef3a87 100644 --- a/zerver/lib/notifications.py +++ b/zerver/lib/notifications.py @@ -393,7 +393,7 @@ def send_future_email(recipients, email_html, email_text, subject, settings.EMAIL_BACKEND != 'django.core.mail.backends.console.EmailBackend': for recipient in recipients: email = recipient.get("email") - if get_user_profile_by_email(email).realm.domain != "zulip.com": + if get_user_profile_by_email(email).realm.string_id != "zulip": raise ValueError("digest: refusing to send emails to non-zulip.com users.") # message = {"from_email": "othello@zulip.com", diff --git a/zerver/tests/test_upload.py b/zerver/tests/test_upload.py index 7f105e0383..d4cc5fef48 100644 --- a/zerver/tests/test_upload.py +++ b/zerver/tests/test_upload.py @@ -184,7 +184,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase): # invalid realm of 999999 (for non-zulip.com) user = get_user_profile_by_email('hamlet@zulip.com') - user.realm.domain = 'example.com' + user.realm.string_id = 'not-zulip' user.realm.save() with use_s3(), getting_realm_id(999999): diff --git a/zerver/views/upload.py b/zerver/views/upload.py index b6198a5c5d..e631d55d56 100644 --- a/zerver/views/upload.py +++ b/zerver/views/upload.py @@ -28,7 +28,7 @@ def serve_s3(request, user_profile, realm_id_str, filename): realm_id = int(realm_id_str) # Internal users can access all uploads so we can receive attachments in cross-realm messages - if user_profile.realm_id == realm_id or user_profile.realm.domain == 'zulip.com': + if user_profile.realm_id == realm_id or user_profile.realm.string_id == 'zulip': uri = get_signed_upload_url(url_path) return redirect(uri) else: