rename notify_user_async celery task to notify_user_about_new_alert_group (#2900)

# What this PR does

Follow up to #2888, rename `notify_user_async` celery task to
`notify_user_about_new_alert_group`.

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
This commit is contained in:
Joey Orlando 2023-08-29 16:02:09 +02:00 committed by GitHub
parent 4a8d0f3ad3
commit 65bceaa297
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 9 deletions

View file

@ -3,7 +3,7 @@ import json
from django.conf import settings
from apps.base.messaging import BaseMessagingBackend
from apps.mobile_app.tasks.new_alert_group import notify_user_async
from apps.mobile_app.tasks.new_alert_group import notify_user_about_new_alert_group
class MobileAppBackend(BaseMessagingBackend):
@ -44,7 +44,7 @@ class MobileAppBackend(BaseMessagingBackend):
return {"connected": MobileAppAuthToken.objects.filter(user=user).exists()}
def notify_user(self, user, alert_group, notification_policy, critical=False):
notify_user_async.delay(
notify_user_about_new_alert_group.delay(
user_pk=user.pk,
alert_group_pk=alert_group.pk,
notification_policy_pk=notification_policy.pk,

View file

@ -2,7 +2,7 @@ from .going_oncall_notification import ( # noqa:F401
conditionally_send_going_oncall_push_notifications_for_all_schedules,
conditionally_send_going_oncall_push_notifications_for_schedule,
)
from .new_alert_group import notify_user_async # noqa:F401
from .new_alert_group import notify_user_about_new_alert_group, notify_user_async # noqa:F401
from .new_shift_swap_request import ( # noqa:F401
notify_shift_swap_request,
notify_shift_swap_requests,

View file

@ -90,7 +90,7 @@ def _get_fcm_message(alert_group: AlertGroup, user: User, device_to_notify: "FCM
@shared_dedicated_queue_retry_task(autoretry_for=(Exception,), retry_backoff=True, max_retries=MAX_RETRIES)
def notify_user_async(user_pk, alert_group_pk, notification_policy_pk, critical):
def notify_user_about_new_alert_group(user_pk, alert_group_pk, notification_policy_pk, critical):
# avoid circular import
from apps.base.models import UserNotificationPolicy, UserNotificationPolicyLogRecord
from apps.mobile_app.models import FCMDevice
@ -137,3 +137,9 @@ def notify_user_async(user_pk, alert_group_pk, notification_policy_pk, critical)
message = _get_fcm_message(alert_group, user, device_to_notify, critical)
send_push_notification(device_to_notify, message, _create_error_log_record)
# TODO: remove this in a future release
@shared_dedicated_queue_retry_task(autoretry_for=(Exception,), retry_backoff=True, max_retries=MAX_RETRIES)
def notify_user_async(user_pk, alert_group_pk, notification_policy_pk, critical):
notify_user_about_new_alert_group(user_pk, alert_group_pk, notification_policy_pk, critical)

View file

@ -4,7 +4,7 @@ import pytest
from apps.base.models import UserNotificationPolicy, UserNotificationPolicyLogRecord
from apps.mobile_app.models import FCMDevice, MobileAppUserSettings
from apps.mobile_app.tasks.new_alert_group import _get_fcm_message, notify_user_async
from apps.mobile_app.tasks.new_alert_group import _get_fcm_message, notify_user_about_new_alert_group
MOBILE_APP_BACKEND_ID = 5
CLOUD_LICENSE_NAME = "Cloud"
@ -13,7 +13,7 @@ OPEN_SOURCE_LICENSE_NAME = "OpenSource"
@patch("apps.mobile_app.tasks.new_alert_group.send_push_notification")
@pytest.mark.django_db
def test_notify_user_async(
def test_notify_user_about_new_alert_group(
mock_send_push_notification,
make_organization_and_user,
make_user_notification_policy,
@ -37,7 +37,7 @@ def test_notify_user_async(
alert_group = make_alert_group(alert_receive_channel, channel_filter=channel_filter)
make_alert(alert_group=alert_group, raw_request_data={})
notify_user_async(
notify_user_about_new_alert_group(
user_pk=user.pk,
alert_group_pk=alert_group.pk,
notification_policy_pk=notification_policy.pk,
@ -49,7 +49,7 @@ def test_notify_user_async(
@patch("apps.mobile_app.tasks.new_alert_group.send_push_notification")
@pytest.mark.django_db
def test_notify_user_async_no_device_connected(
def test_notify_user_about_new_alert_group_no_device_connected(
mock_send_push_notification,
make_organization_and_user,
make_user_notification_policy,
@ -72,7 +72,7 @@ def test_notify_user_async_no_device_connected(
alert_group = make_alert_group(alert_receive_channel, channel_filter=channel_filter)
make_alert(alert_group=alert_group, raw_request_data={})
notify_user_async(
notify_user_about_new_alert_group(
user_pk=user.pk,
alert_group_pk=alert_group.pk,
notification_policy_pk=notification_policy.pk,

View file

@ -112,7 +112,9 @@ CELERY_TASK_ROUTES = {
"apps.integrations.tasks.create_alert": {"queue": "critical"},
"apps.integrations.tasks.create_alertmanager_alerts": {"queue": "critical"},
"apps.integrations.tasks.start_notify_about_integration_ratelimit": {"queue": "critical"},
# TODO: remove apps.mobile_app.tasks.notify_user_async in a future release
"apps.mobile_app.tasks.notify_user_async": {"queue": "critical"},
"apps.mobile_app.tasks.notify_user_about_new_alert_group": {"queue": "critical"},
"apps.schedules.tasks.drop_cached_ical.drop_cached_ical_for_custom_events_for_organization": {"queue": "critical"},
"apps.schedules.tasks.drop_cached_ical.drop_cached_ical_task": {"queue": "critical"},
# LONG