Compare commits
	
		
			No commits in common. "6b30769d968dd0ca24ed1393304a83c0cbddb532" and "c9329a33ea2a901b5cc45d2f82d53f4b9c7dc991" have entirely different histories.
		
	
	
		
			6b30769d96
			...
			c9329a33ea
		
	
		
@ -1,5 +1,5 @@
 | 
			
		||||
[tool.bumpversion]
 | 
			
		||||
current_version = "1.3.28"
 | 
			
		||||
current_version = "1.3.27"
 | 
			
		||||
commit = true
 | 
			
		||||
tag = true
 | 
			
		||||
tag_name = "{new_version}"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										38
									
								
								app.py
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								app.py
									
									
									
									
									
								
							@ -6,6 +6,7 @@ import requests.auth
 | 
			
		||||
import os
 | 
			
		||||
import base64
 | 
			
		||||
from typing import Dict, Any, Tuple, Union
 | 
			
		||||
from pywebpush import webpush, WebPushException
 | 
			
		||||
 | 
			
		||||
from lib.datetime import filter_accounts_next_30_days, filter_accounts_expired
 | 
			
		||||
from lib.reqs import (get_urls, get_user_accounts, add_user_account,
 | 
			
		||||
@ -90,35 +91,26 @@ def index() -> Union[Response, str]:
 | 
			
		||||
        return redirect(url_for("home"))
 | 
			
		||||
    return render_template("index.html")
 | 
			
		||||
 | 
			
		||||
@app.route('/vapid-public-key', methods=['GET'])
 | 
			
		||||
def proxy_vapid_public_key():
 | 
			
		||||
    """Proxies the request for the VAPID public key to the backend."""
 | 
			
		||||
    backend_url = f"{app.config['BASE_URL']}/vapid-public-key"
 | 
			
		||||
    try:
 | 
			
		||||
        response = requests.get(backend_url)
 | 
			
		||||
        return Response(response.content, status=response.status_code, mimetype=response.headers['Content-Type'])
 | 
			
		||||
    except requests.exceptions.RequestException as e:
 | 
			
		||||
        return jsonify({"error": str(e)}), 502
 | 
			
		||||
@app.route('/vapid-public-key')
 | 
			
		||||
def vapid_public_key():
 | 
			
		||||
    """Provides the VAPID public key to the client."""
 | 
			
		||||
    return jsonify({'public_key': app.config['VAPID_PUBLIC_KEY']})
 | 
			
		||||
 | 
			
		||||
@app.route('/save-subscription', methods=['POST'])
 | 
			
		||||
def proxy_save_subscription():
 | 
			
		||||
    """Proxies the request to save a push subscription to the backend."""
 | 
			
		||||
def save_subscription():
 | 
			
		||||
    """Saves a push notification subscription."""
 | 
			
		||||
    if not session.get("logged_in"):
 | 
			
		||||
        return jsonify({'error': 'Unauthorized'}), 401
 | 
			
		||||
 | 
			
		||||
    backend_url = f"{app.config['BASE_URL']}/save-subscription"
 | 
			
		||||
    credentials = base64.b64decode(session["auth_credentials"]).decode()
 | 
			
		||||
    username, password = credentials.split(":", 1)
 | 
			
		||||
    subscription_data = request.get_json()
 | 
			
		||||
    if not subscription_data:
 | 
			
		||||
        return jsonify({'error': 'No subscription data received'}), 400
 | 
			
		||||
 | 
			
		||||
    try:
 | 
			
		||||
        response = requests.post(
 | 
			
		||||
            backend_url,
 | 
			
		||||
            auth=requests.auth.HTTPBasicAuth(username, password),
 | 
			
		||||
            json=request.get_json()
 | 
			
		||||
        )
 | 
			
		||||
        return Response(response.content, status=response.status_code, mimetype=response.headers['Content-Type'])
 | 
			
		||||
    except requests.exceptions.RequestException as e:
 | 
			
		||||
        return jsonify({"error": str(e)}), 502
 | 
			
		||||
    # Here you would typically save the subscription to a database
 | 
			
		||||
    # For this example, we'll just store it in the session
 | 
			
		||||
    session['push_subscription'] = subscription_data
 | 
			
		||||
    print(f"Subscription saved for user: {session['username']}")
 | 
			
		||||
    return jsonify({'success': True})
 | 
			
		||||
 | 
			
		||||
@app.route("/home")
 | 
			
		||||
@cache.cached(timeout=60)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user