|  |  | @ -150,11 +150,27 @@ class WebPushService(): | 
			
		
	
		
			
				
					|  |  |  |                 vapid_private_key=vapid_key.private_key, | 
			
		
	
		
			
				
					|  |  |  |                 vapid_claims={"sub": CONTACT_EMAIL} | 
			
		
	
		
			
				
					|  |  |  |             ) | 
			
		
	
		
			
				
					|  |  |  |             time.sleep(1) | 
			
		
	
		
			
				
					|  |  |  |             return True | 
			
		
	
		
			
				
					|  |  |  |          | 
			
		
	
		
			
				
					|  |  |  |         except WebPushException as ex: | 
			
		
	
		
			
				
					|  |  |  |             print(f"Failed to send push notification for {subscription_info['endpoint']} -- {ex}") | 
			
		
	
		
			
				
					|  |  |  |             return False | 
			
		
	
		
			
				
					|  |  |  |             now = datetime.datetime.now().isoformat() | 
			
		
	
		
			
				
					|  |  |  |             endpoint = subscription_info['endpoint'] | 
			
		
	
		
			
				
					|  |  |  |             print(f"{now}: Failed to send push notification for {endpoint} -- {ex}") | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             unsubscribed_msg = '410 Gone' | 
			
		
	
		
			
				
					|  |  |  |             if unsubscribed_msg in ex.args[0]: | 
			
		
	
		
			
				
					|  |  |  |                 subscription = Subscription.query.filter_by(endpoint=endpoint).first() | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                 # Delete the subscription if found | 
			
		
	
		
			
				
					|  |  |  |                 if subscription: | 
			
		
	
		
			
				
					|  |  |  |                     db.session.delete(subscription) | 
			
		
	
		
			
				
					|  |  |  |                     db.session.commit() | 
			
		
	
		
			
				
					|  |  |  |                     print(f"Committed delete of {subscription_info}") | 
			
		
	
		
			
				
					|  |  |  |                 else: | 
			
		
	
		
			
				
					|  |  |  |                     print(f"Could not find subscription at: {endpoint}") | 
			
		
	
		
			
				
					|  |  |  |             else: | 
			
		
	
		
			
				
					|  |  |  |                 print("Wrong error.", ex.args[0]) | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     def _send_daily_notifications(self) -> None: | 
			
		
	
	
		
			
				
					|  |  | 
 |