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.

settings: Set enable_marketing_emails after copying user settings.

Sahil Batra03a0cfda6426
diff --git a/zerver/lib/create_user.py b/zerver/lib/create_user.py
index 0ca516b3e41..6bde5346da2 100644
--- a/zerver/lib/create_user.py
+++ b/zerver/lib/create_user.py
@@ -142,7 +142,6 @@ def create_user(
user_profile.timezone = timezone
user_profile.default_sending_stream = default_sending_stream
user_profile.default_events_register_stream = default_events_register_stream
- user_profile.enable_marketing_emails = enable_marketing_emails
if role is not None:
user_profile.role = role
# Allow the ORM default to be used if not provided
@@ -161,6 +160,10 @@ def create_user(
else:
user_profile.save()
+ if bot_type is None:
+ user_profile.enable_marketing_emails = enable_marketing_emails
+ user_profile.save(update_fields=["enable_marketing_emails"])
+
if not user_profile.email_address_is_realm_public():
# With restricted access to email addresses, we can't generate
# the fake email addresses we use for display purposes without
diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py
index b157daa8eec..7fdf9109987 100644
--- a/zerver/tests/test_signup.py
+++ b/zerver/tests/test_signup.py
@@ -847,7 +847,7 @@ class LoginTest(ZulipTestCase):
with queries_captured() as queries, cache_tries_captured() as cache_tries:
self.register(self.nonreg_email("test"), "test")
# Ensure the number of queries we make is not O(streams)
- self.assert_length(queries, 87)
+ self.assert_length(queries, 88)
# We can probably avoid a couple cache hits here, but there doesn't
# seem to be any O(N) behavior. Some of the cache hits are related
diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py
index 4697798bcfa..cf9edbbc54d 100644
--- a/zerver/tests/test_users.py
+++ b/zerver/tests/test_users.py
@@ -795,7 +795,7 @@ class QueryCountTest(ZulipTestCase):
acting_user=None,
)
- self.assert_length(queries, 82)
+ self.assert_length(queries, 83)
self.assert_length(cache_tries, 27)
peer_add_events = [event for event in events if event["event"].get("op") == "peer_add"]