snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
This commit is contained in:
72
zerver/worker/missedmessage_mobile_notifications.py
Normal file
72
zerver/worker/missedmessage_mobile_notifications.py
Normal file
@@ -0,0 +1,72 @@
|
||||
# Documented in https://zulip.readthedocs.io/en/latest/subsystems/queuing.html
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from django.conf import settings
|
||||
from typing_extensions import override
|
||||
|
||||
from zerver.lib.push_notifications import (
|
||||
handle_push_notification,
|
||||
handle_remove_push_notification,
|
||||
initialize_push_notifications,
|
||||
)
|
||||
from zerver.lib.push_registration import handle_register_push_device_to_bouncer
|
||||
from zerver.lib.queue import retry_event
|
||||
from zerver.lib.remote_server import PushNotificationBouncerRetryLaterError
|
||||
from zerver.worker.base import QueueProcessingWorker, assign_queue
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@assign_queue("missedmessage_mobile_notifications")
|
||||
class PushNotificationsWorker(QueueProcessingWorker):
|
||||
# The use of aioapns in the backend means that we cannot use
|
||||
# SIGALRM to limit how long a consume takes, as SIGALRM does not
|
||||
# play well with asyncio.
|
||||
MAX_CONSUME_SECONDS = None
|
||||
|
||||
@override
|
||||
def __init__(
|
||||
self,
|
||||
threaded: bool = False,
|
||||
disable_timeout: bool = False,
|
||||
worker_num: int | None = None,
|
||||
) -> None:
|
||||
if settings.MOBILE_NOTIFICATIONS_SHARDS > 1 and worker_num is not None: # nocoverage
|
||||
self.queue_name += f"_shard{worker_num}"
|
||||
super().__init__(threaded, disable_timeout, worker_num)
|
||||
|
||||
@override
|
||||
def start(self) -> None:
|
||||
# initialize_push_notifications doesn't strictly do anything
|
||||
# beyond printing some logging warnings if push notifications
|
||||
# are not available in the current configuration.
|
||||
initialize_push_notifications()
|
||||
super().start()
|
||||
|
||||
@override
|
||||
def consume(self, event: dict[str, Any]) -> None:
|
||||
try:
|
||||
event_type = event.get("type")
|
||||
if event_type == "register_push_device_to_bouncer":
|
||||
handle_register_push_device_to_bouncer(event["payload"])
|
||||
elif event_type == "remove":
|
||||
message_ids = event["message_ids"]
|
||||
handle_remove_push_notification(event["user_profile_id"], message_ids)
|
||||
else:
|
||||
handle_push_notification(event["user_profile_id"], event)
|
||||
except PushNotificationBouncerRetryLaterError:
|
||||
|
||||
def failure_processor(event: dict[str, Any]) -> None:
|
||||
if event_type == "register_push_device_to_bouncer":
|
||||
logger.warning(
|
||||
"Maximum retries exceeded for device_id:%s event:register_push_device_to_bouncer",
|
||||
event["payload"]["device_id"],
|
||||
)
|
||||
else:
|
||||
logger.warning(
|
||||
"Maximum retries exceeded for trigger:%s event:push_notification",
|
||||
event["user_profile_id"],
|
||||
)
|
||||
|
||||
retry_event(self.queue_name, event, failure_processor)
|
||||
Reference in New Issue
Block a user