| 
						
						
							
								
							
						
						
					 | 
					@ -154,7 +154,7 @@ class WebPushService(): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            ) | 
					 | 
					 | 
					            ) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            # "because sometimes that's what I had to do to make it work!" - Matthew | 
					 | 
					 | 
					            # "because sometimes that's what I had to do to make it work!" - Matthew | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            time.sleep(1) | 
					 | 
					 | 
					            time.sleep(1) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            return {"success": True, "message": result.text, "result": result} | 
					 | 
					 | 
					            return {"success": result["status_code"] == 201, "message": result.text, "result": result} | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        except WebPushException as ex: | 
					 | 
					 | 
					        except WebPushException as ex: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            now = datetime.datetime.now().isoformat() | 
					 | 
					 | 
					            now = datetime.datetime.now().isoformat() | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -162,6 +162,7 @@ class WebPushService(): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            print(f"{now}: Failed to send push notification for {endpoint} -- {ex}", flush=True) | 
					 | 
					 | 
					            print(f"{now}: Failed to send push notification for {endpoint} -- {ex}", flush=True) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            unsubscribed_msg = '410 Gone' | 
					 | 
					 | 
					            unsubscribed_msg = '410 Gone' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            unsubscribed = False | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            if unsubscribed_msg in ex.args[0]: | 
					 | 
					 | 
					            if unsubscribed_msg in ex.args[0]: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                subscription = Subscription.query.filter_by(endpoint=endpoint).first() | 
					 | 
					 | 
					                subscription = Subscription.query.filter_by(endpoint=endpoint).first() | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -170,12 +171,13 @@ class WebPushService(): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    db.session.delete(subscription) | 
					 | 
					 | 
					                    db.session.delete(subscription) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    db.session.commit() | 
					 | 
					 | 
					                    db.session.commit() | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    print(f"Committed delete of {subscription_info}", flush=True) | 
					 | 
					 | 
					                    print(f"Committed delete of {subscription_info}", flush=True) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    unsubscribed = True | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                else: | 
					 | 
					 | 
					                else: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    print(f"Could not find subscription at: {endpoint}", flush=True) | 
					 | 
					 | 
					                    print(f"Could not find subscription at: {endpoint}", flush=True) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            else: | 
					 | 
					 | 
					            else: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                print("Error other than unsubscribed/expired.", ex.args[0], flush=True) | 
					 | 
					 | 
					                print("Error other than unsubscribed/expired.", ex.args[0], flush=True) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            return {"success": False, "message": ex.args[0]} | 
					 | 
					 | 
					            return {"success": False, "message": ex.args[0], "error": ex, "unsubscribed": unsubscribed} | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    def _send_daily_notifications(self) -> None: | 
					 | 
					 | 
					    def _send_daily_notifications(self) -> None: | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -367,7 +369,7 @@ class WebPushService(): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        result = WebPushService._send_push_notification(subscription_info, message, vapid_key) | 
					 | 
					 | 
					        result = WebPushService._send_push_notification(subscription_info, message, vapid_key) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        # Returning the operation status | 
					 | 
					 | 
					        # Returning the operation status | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        return jsonify(success=result["status_code"]==201, message=result["text"]) | 
					 | 
					 | 
					        return jsonify(success=result["success"], message=result["message"]) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @staticmethod | 
					 | 
					 | 
					    @staticmethod | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -464,10 +466,7 @@ class WebPushService(): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                {"title": title, "message": message}, | 
					 | 
					 | 
					                {"title": title, "message": message}, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                vapid_key | 
					 | 
					 | 
					                vapid_key | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            ) | 
					 | 
					 | 
					            ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            return jsonify( | 
					 | 
					 | 
					            return jsonify(success=result["success"], message=result["message"]) | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					                success=result["result"].status_code==201, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                message=result["result"].text, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            ) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        else: | 
					 | 
					 | 
					        else: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            return jsonify({"success": False, "message": "Subscription not found"}), 404 | 
					 | 
					 | 
					            return jsonify({"success": False, "message": "Subscription not found"}), 404 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |