mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 02:17:19 +00:00
notifications: Optimize push notifications code path in tests.
This checks if push_notification_enabled() is set to false in handle_push_notification and adds an early return statement. This is a significant performance optimization for our unit tests because the push notifications code path does a number of database queries, and this migration means we don't end up doing those queries the hundreds of times we send PMs or mentions in our tests where we're not trying to test the push notifications functionality. This should also have a small message sending scalability improvement for any Zulip servers without push notifications enabled. Tweaked by tabbott to fix a few small issues. Fixes #10895.
This commit is contained in:
@@ -649,6 +649,8 @@ def handle_push_notification(user_profile_id: int, missed_message: Dict[str, Any
|
||||
missed_message is the event received by the
|
||||
zerver.worker.queue_processors.PushNotificationWorker.consume function.
|
||||
"""
|
||||
if not push_notifications_enabled():
|
||||
return
|
||||
user_profile = get_user_profile_by_id(user_profile_id)
|
||||
if not (receives_offline_push_notifications(user_profile) or
|
||||
receives_online_notifications(user_profile)):
|
||||
|
||||
Reference in New Issue
Block a user