fix bug in the "you're going oncall" push notification copy (#1922)
# What this PR does ## Which issue(s) this PR fixes User reported receiving a push notification that they were going oncall ~12mins before the shift started but the notification copy instead showed this:  ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
This commit is contained in:
parent
b5ee08e04d
commit
395dfd37d0
3 changed files with 17 additions and 7 deletions
|
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix bug in the "You're Going Oncall" push notification copy by @joeyorlando ([#1922](https://github.com/grafana/oncall/pull/1922))
|
||||
|
||||
## v1.2.21 (2023-05-09)
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -314,6 +314,9 @@ def should_we_send_going_oncall_push_notification(
|
|||
Currently we will send notifications for the following scenarios:
|
||||
- schedule is starting in user's "configured notification timing preference" +/- a 4 minute buffer
|
||||
- schedule is starting within the next fifteen minutes
|
||||
|
||||
Returns `None` if conditions are not met for the user to receive a push notification. Otherwise returns
|
||||
an `int` which represents the # of seconds until the oncall shift starts.
|
||||
"""
|
||||
NOTIFICATION_TIMING_BUFFER = 7 * 60 # 7 minutes in seconds
|
||||
FIFTEEN_MINUTES_IN_SECONDS = 15 * 60
|
||||
|
|
@ -417,13 +420,13 @@ def conditionally_send_going_oncall_push_notifications_for_schedule(schedule_pk)
|
|||
|
||||
cache_key = _generate_going_oncall_push_notification_cache_key(user_pk, schedule_event)
|
||||
already_sent_this_push_notification = cache_key in relevant_notifications_already_sent
|
||||
seconds_until_going_oncall = should_we_send_going_oncall_push_notification(
|
||||
now, mobile_app_user_settings, schedule_event
|
||||
)
|
||||
|
||||
if (
|
||||
should_we_send_going_oncall_push_notification(now, mobile_app_user_settings, schedule_event)
|
||||
and not already_sent_this_push_notification
|
||||
):
|
||||
if seconds_until_going_oncall is not None and not already_sent_this_push_notification:
|
||||
message = _get_youre_going_oncall_fcm_message(
|
||||
user, schedule, device_to_notify, mobile_app_user_settings.going_oncall_notification_timing
|
||||
user, schedule, device_to_notify, seconds_until_going_oncall
|
||||
)
|
||||
_send_push_notification(device_to_notify, message)
|
||||
cache.set(cache_key, True, PUSH_NOTIFICATION_TRACKING_CACHE_KEY_TTL)
|
||||
|
|
|
|||
|
|
@ -217,8 +217,9 @@ def test_conditionally_send_going_oncall_push_notifications_for_schedule(
|
|||
),
|
||||
]
|
||||
|
||||
seconds_until_shift_starts = 58989
|
||||
mock_get_youre_going_oncall_fcm_message.return_value = mock_fcm_message
|
||||
mock_should_we_send_going_oncall_push_notification.return_value = True
|
||||
mock_should_we_send_going_oncall_push_notification.return_value = seconds_until_shift_starts
|
||||
mock_oncall_schedule_final_events.return_value = final_events
|
||||
|
||||
schedule = make_schedule(organization, schedule_class=OnCallScheduleWeb)
|
||||
|
|
@ -236,7 +237,7 @@ def test_conditionally_send_going_oncall_push_notifications_for_schedule(
|
|||
|
||||
tasks.conditionally_send_going_oncall_push_notifications_for_schedule(schedule.pk)
|
||||
|
||||
mock_get_youre_going_oncall_fcm_message.assert_called_once_with(user, schedule, device, ONCALL_TIMING_PREFERENCE)
|
||||
mock_get_youre_going_oncall_fcm_message.assert_called_once_with(user, schedule, device, seconds_until_shift_starts)
|
||||
mock_send_push_notification.assert_called_once_with(device, mock_fcm_message)
|
||||
assert cache.get(cache_key) is True
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue