From 4536f2268c33f81a74eca91b030f114667ee3ff3 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Mon, 11 Dec 2023 17:53:47 -0700 Subject: [PATCH] update email for production --- app.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index e73a4f1..f5868da 100644 --- a/app.py +++ b/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.