Browse Source

update email for production

test-message
Trent Larson 9 months ago
parent
commit
4536f2268c
  1. 9
      app.py

9
app.py

@ -8,6 +8,7 @@ from cryptography.hazmat.primitives.asymmetric import ec
from pywebpush import webpush, WebPushException
import base64
import datetime
import json
import os
import threading
@ -15,6 +16,8 @@ import time
app = Flask(__name__)
CONTACT_EMAIL = "mailto:info@timesafari.app"
class WebPushService():
"""
This class provides services for sending web push notifications.
@ -140,7 +143,7 @@ class WebPushService():
subscription_info=subscription_info,
data=json.dumps(message),
vapid_private_key=vapid_key.private_key,
vapid_claims={"sub": "mailto:matthew.raymer@gmail.com"}
vapid_claims={"sub": CONTACT_EMAIL}
)
return True
@ -178,7 +181,8 @@ class WebPushService():
vapid_key = VAPIDKey.query.first()
# Constructing the push notification message
message = {"title": "Daily Update", "message": "Here's your daily update!"}
now = datetime.datetime.now().isoformat()
message = {"title": "Daily Update", "message": f"Update for {now}"}
# Sending a push notification to each subscribed client
for subscription in all_subscriptions:
@ -195,6 +199,7 @@ class WebPushService():
time.sleep(24 * 60 * 60)
# This is an endpoint, routed in __init__
def regenerate_vapid(self) -> Tuple[str, int]:
"""
Endpoint to regenerate VAPID keys.

Loading…
Cancel
Save