Fixes notify.html5 for notifications on FireFox (#12993)

* Only pass the gcm_key when using Google Cloud Messaging as endpoint.

* Test if the gcm_key is only included for GCM endpoints.
This commit is contained in:
corneyl
2018-03-09 02:50:17 +01:00
committed by Paulus Schoutsen
parent 19a529e917
commit 2ee73ca911
2 changed files with 44 additions and 3 deletions

View File

@@ -404,8 +404,14 @@ class HTML5NotificationService(BaseNotificationService):
jwt_token = jwt.encode(jwt_claims, jwt_secret).decode('utf-8')
payload[ATTR_DATA][ATTR_JWT] = jwt_token
# Only pass the gcm key if we're actually using GCM
# If we don't, notifications break on FireFox
gcm_key = self._gcm_key \
if 'googleapis.com' in info[ATTR_SUBSCRIPTION][ATTR_ENDPOINT] \
else None
response = WebPusher(info[ATTR_SUBSCRIPTION]).send(
json.dumps(payload), gcm_key=self._gcm_key, ttl='86400')
json.dumps(payload), gcm_key=gcm_key, ttl='86400'
)
# pylint: disable=no-member
if response.status_code == 410: