diff --git a/zerver/lib/zcommand.py b/zerver/lib/zcommand.py index cb679c0586..4cad092932 100644 --- a/zerver/lib/zcommand.py +++ b/zerver/lib/zcommand.py @@ -19,7 +19,10 @@ def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any] ) ) do_change_user_setting( - user_profile=user_profile, setting_name=setting, setting_value=setting_value + user_profile=user_profile, + setting_name=setting, + setting_value=setting_value, + acting_user=user_profile, ) return msg diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index d267c73264..9e59b003a0 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -2065,6 +2065,7 @@ class NormalActionsTest(BaseAction): self.user_profile, "default_view", "all_messages", + acting_user=self.user_profile, ), state_change_expected=True, user_settings_object=True, @@ -2195,7 +2196,9 @@ class UserDisplayActionTest(BaseAction): for value in values: events = self.verify_action( - lambda: do_change_user_setting(self.user_profile, setting_name, value), + lambda: do_change_user_setting( + self.user_profile, setting_name, value, acting_user=self.user_profile + ), num_events=num_events, ) @@ -2215,7 +2218,9 @@ class UserDisplayActionTest(BaseAction): for value in values: events = self.verify_action( - lambda: do_change_user_setting(self.user_profile, "timezone", value), + lambda: do_change_user_setting( + self.user_profile, "timezone", value, acting_user=self.user_profile + ), num_events=num_events, ) @@ -2347,7 +2352,9 @@ class SubscribeActionTest(BaseAction): class DraftActionTest(BaseAction): def do_enable_drafts_synchronization(self, user_profile: UserProfile) -> None: - do_change_user_setting(user_profile, "enable_drafts_synchronization", True) + do_change_user_setting( + user_profile, "enable_drafts_synchronization", True, acting_user=self.user_profile + ) def test_draft_create_event(self) -> None: self.do_enable_drafts_synchronization(self.user_profile) diff --git a/zerver/tests/test_markdown.py b/zerver/tests/test_markdown.py index f7f47ad8f1..9d28635504 100644 --- a/zerver/tests/test_markdown.py +++ b/zerver/tests/test_markdown.py @@ -436,7 +436,9 @@ class MarkdownTest(ZulipTestCase): if test.get("translate_emoticons", False): # Create a userprofile and send message with it. user_profile = self.example_user("othello") - do_change_user_setting(user_profile, "translate_emoticons", True) + do_change_user_setting( + user_profile, "translate_emoticons", True, acting_user=None + ) msg = Message(sender=user_profile, sending_client=get_client("test")) rendering_result = render_markdown(msg, test["input"]) converted = rendering_result.rendered_content @@ -1219,7 +1221,7 @@ class MarkdownTest(ZulipTestCase): def test_no_translate_emoticons_if_off(self) -> None: user_profile = self.example_user("othello") - do_change_user_setting(user_profile, "translate_emoticons", False) + do_change_user_setting(user_profile, "translate_emoticons", False, acting_user=None) msg = Message(sender=user_profile, sending_client=get_client("test")) content = ":)" diff --git a/zerver/views/registration.py b/zerver/views/registration.py index 6b54fa1a2e..69bf42b809 100644 --- a/zerver/views/registration.py +++ b/zerver/views/registration.py @@ -420,7 +420,7 @@ def accounts_register( do_activate_mirror_dummy_user(user_profile, acting_user=user_profile) do_change_password(user_profile, password) do_change_full_name(user_profile, full_name, user_profile) - do_change_user_setting(user_profile, "timezone", timezone) + do_change_user_setting(user_profile, "timezone", timezone, acting_user=user_profile) # TODO: When we clean up the `do_activate_mirror_dummy_user` code path, # make it respect invited_as_admin / is_realm_admin. diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py index 05898a0348..f25ab5c09e 100644 --- a/zerver/views/user_settings.py +++ b/zerver/views/user_settings.py @@ -266,7 +266,7 @@ def json_change_settings( } for k, v in list(request_settings.items()): if v is not None and getattr(user_profile, k) != v: - do_change_user_setting(user_profile, k, v) + do_change_user_setting(user_profile, k, v, acting_user=user_profile) req_vars = { k: v for k, v in list(locals().items()) if k in user_profile.notification_setting_types @@ -277,7 +277,7 @@ def json_change_settings( do_change_notification_settings(user_profile, k, v, acting_user=user_profile) if timezone is not None and user_profile.timezone != timezone: - do_change_user_setting(user_profile, "timezone", timezone) + do_change_user_setting(user_profile, "timezone", timezone, acting_user=user_profile) # TODO: Do this more generally. from zerver.lib.request import RequestNotes