Skip to content

Commit

Permalink
Demo: Checking CI testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
shuklamaneesh23 committed Dec 28, 2024
1 parent 5882237 commit d7dcff1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
30 changes: 29 additions & 1 deletion zerver/actions/user_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from confirmation.models import Confirmation, create_confirmation_link
from confirmation.settings import STATUS_REVOKED
from zerver.actions.message_send import internal_send_private_message
from zerver.actions.presence import do_update_user_presence
from zerver.lib.avatar import avatar_url
from zerver.lib.cache import (
Expand All @@ -18,6 +19,7 @@
)
from zerver.lib.create_user import get_display_email_address
from zerver.lib.i18n import get_language_name
from zerver.lib.mention import silent_mention_syntax_for_user
from zerver.lib.queue import queue_event_on_commit
from zerver.lib.send_email import FromAddress, clear_scheduled_emails, send_email
from zerver.lib.timezone import canonicalize_timezone
Expand All @@ -42,7 +44,7 @@
)
from zerver.models.clients import get_client
from zerver.models.realm_audit_logs import AuditLogEventType
from zerver.models.users import bot_owner_user_ids, get_user_profile_by_id
from zerver.models.users import bot_owner_user_ids, get_system_bot, get_user_profile_by_id
from zerver.tornado.django_api import send_event_on_commit


Expand Down Expand Up @@ -247,6 +249,9 @@ def do_change_full_name(
dict(type="realm_bot", op="update", bot=payload),
bot_owner_user_ids(user_profile),
)
send_account_modification_notifications(
user_profile, "full name", acting_user, old_name, full_name
)


def check_change_full_name(
Expand Down Expand Up @@ -607,3 +612,26 @@ def do_change_user_setting(
force_send_update=True,
)
)


def send_account_modification_notifications(
user_profile: UserProfile,
property: str,
acting_user: UserProfile | None,
old_value: str | list[int] | None,
new_value: str | list[int] | None,
) -> None:
if user_profile.is_bot or acting_user == user_profile or acting_user is None:
return

realm = user_profile.realm
sender = get_system_bot(settings.NOTIFICATION_BOT, realm.id)
if acting_user:
detailed_message = f"{silent_mention_syntax_for_user(acting_user)} has updated your `{property}`.\n\n- **Old `{property}`:** {old_value}\n- **New `{property}`:** {new_value}"
else:
detailed_message = f"The following updates have been made to your account.\n\n- **Old `{property}`:** {old_value}\n- **New `{property}`:** {new_value}"
internal_send_private_message(
sender,
user_profile,
detailed_message,
)
1 change: 1 addition & 0 deletions zerver/tests/test_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ def test_zulip_realm(self) -> None:

data = read_json("messages-000001.json")
um = UserMessage.objects.all()[0]
print(um)
exported_um = self.find_by_id(data["zerver_usermessage"], um.id)
self.assertEqual(exported_um["message"], um.message_id)
self.assertEqual(exported_um["user_profile"], um.user_profile_id)
Expand Down

0 comments on commit d7dcff1

Please sign in to comment.