Skip to content

Commit 4a2ecd8

Browse files
committed
It was documented that a timeout could be set for webpushes, but there was no logic behind it.
1 parent 16d43c2 commit 4a2ecd8

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

push_notifications/conf/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def _validate_wp_config(self, application_id, application_config):
218218
"EDGE": "https://wns2-par02p.notify.windows.com/w",
219219
"FIREFOX": "https://updates.push.services.mozilla.com/wpush/v2",
220220
})
221+
application_config.setdefault("ERROR_TIMEOUT", 1)
221222

222223
def _validate_allowed_settings(self, application_id, application_config, allowed_settings):
223224
"""Confirm only allowed settings are present."""
@@ -349,3 +350,6 @@ def get_wp_private_key(self, application_id=None):
349350

350351
def get_wp_claims(self, application_id=None):
351352
return self._get_application_settings(application_id, "WP", "CLAIMS")
353+
354+
def get_wp_error_timeout(self, application_id=None):
355+
return self._get_application_settings(application_id, "WP", "ERROR_TIMEOUT")

push_notifications/conf/legacy.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,7 @@ def get_wp_private_key(self, application_id=None):
128128
def get_wp_claims(self, application_id=None):
129129
msg = "Setup PUSH_NOTIFICATIONS_SETTINGS properly to send messages"
130130
return self._get_application_settings(application_id, "WP_CLAIMS", msg)
131+
132+
def get_wp_error_timeout(self, application_id=None):
133+
msg = "Setup PUSH_NOTIFICATIONS_SETTINGS properly to set a timeout"
134+
return self._get_application_settings(application_id, "WP_ERROR_TIMEOUT", msg)

push_notifications/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
})
4141
PUSH_NOTIFICATIONS_SETTINGS.setdefault("WP_PRIVATE_KEY", None)
4242
PUSH_NOTIFICATIONS_SETTINGS.setdefault("WP_CLAIMS", None)
43-
PUSH_NOTIFICATIONS_SETTINGS.setdefault("WP_ERROR_TIMEOUT", None)
43+
PUSH_NOTIFICATIONS_SETTINGS.setdefault("WP_ERROR_TIMEOUT", 1)
4444

4545
# User model
4646
PUSH_NOTIFICATIONS_SETTINGS.setdefault("USER_MODEL", settings.AUTH_USER_MODEL)

push_notifications/webpush.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def webpush_send_message(device, message, **kwargs):
3737
data=message,
3838
vapid_private_key=get_manager().get_wp_private_key(device.application_id),
3939
vapid_claims=get_manager().get_wp_claims(device.application_id).copy(),
40+
timeout=get_manager().get_wp_error_timeout(device.application_id),
4041
**kwargs
4142
)
4243
if response.ok:

0 commit comments

Comments
 (0)