CLEANUP: Tidied up backend code removed unused imports and debugging print statements

This commit is contained in:
JustIceO7
2025-03-06 17:26:41 +00:00
parent 9119df70b9
commit 5e9345463a
5 changed files with 19 additions and 38 deletions

View File

@@ -3,7 +3,6 @@ from werkzeug.security import generate_password_hash, check_password_hash
from flask_cors import cross_origin from flask_cors import cross_origin
from database.database import Database from database.database import Database
from blueprints.middleware import login_required from blueprints.middleware import login_required
from utils.email import send_email
from utils.user_utils import get_user_id from utils.user_utils import get_user_id
from utils.utils import sanitize from utils.utils import sanitize
from secrets import token_hex from secrets import token_hex
@@ -95,7 +94,6 @@ def signup():
# Create user directories for stream data # Create user directories for stream data
path_manager.create_user(username) path_manager.create_user(username)
# send_email(username)
return jsonify({ return jsonify({
"account_created": True, "account_created": True,
@@ -113,7 +111,6 @@ def signup():
db.close_connection() db.close_connection()
@auth_bp.route("/login", methods=["POST"]) @auth_bp.route("/login", methods=["POST"])
@cross_origin(supports_credentials=True) @cross_origin(supports_credentials=True)
def login(): def login():

View File

@@ -84,7 +84,6 @@ def google_auth():
return jsonify({'error': 'Missing nonce in session'}), 400 return jsonify({'error': 'Missing nonce in session'}), 400
user = google.parse_id_token(token, nonce=nonce) user = google.parse_id_token(token, nonce=nonce)
print(user, flush=True)
# Check if email exists to login else create a database entry # Check if email exists to login else create a database entry
user_email = user.get("email") user_email = user.get("email")

View File

@@ -16,7 +16,6 @@ def create_checkout_session():
""" """
Creates the stripe checkout session Creates the stripe checkout session
""" """
print("Creating checkout session", flush=True)
try: try:
# Checks to see who is subscribing to who # Checks to see who is subscribing to who
user_id = s.get("user_id") user_id = s.get("user_id")
@@ -35,7 +34,6 @@ def create_checkout_session():
client_reference_id = f"{user_id}-{streamer_id}" client_reference_id = f"{user_id}-{streamer_id}"
) )
except Exception as e: except Exception as e:
print(e, flush=True)
return str(e), 500 return str(e), 500
return jsonify(clientSecret=session.client_secret) return jsonify(clientSecret=session.client_secret)
@@ -74,7 +72,6 @@ def stripe_webhook():
if product_id == subscription: if product_id == subscription:
client_reference_id = session.get("client_reference_id") client_reference_id = session.get("client_reference_id")
user_id, streamer_id = map(int, client_reference_id.split("-")) user_id, streamer_id = map(int, client_reference_id.split("-"))
print(f"user_id: {user_id} is subscribing to streamer_id: {streamer_id}", flush=True)
subscribe(user_id, streamer_id) subscribe(user_id, streamer_id)
return "Success", 200 return "Success", 200

View File

@@ -8,7 +8,6 @@ from utils.path_manager import PathManager
from celery_tasks.streaming import convert_image_to_png from celery_tasks.streaming import convert_image_to_png
import redis import redis
from io import BytesIO
from PIL import Image from PIL import Image
redis_url = "redis://redis:6379/1" redis_url = "redis://redis:6379/1"

View File

@@ -165,16 +165,14 @@ def newsletter_conf(email):
""" """
# Check if user is already in database # Check if user is already in database
db = Database() with Database() as db:
db.create_connection()
user_exists = db.fetchone(""" user_exists = db.fetchone("""
SELECT * SELECT *
FROM newsletter FROM newsletter
WHERE email = ?;""", WHERE email = ?;""",
(email,)) (email,))
print(user_exists, flush=True) print(user_exists, flush=True)
db.close_connection()
if user_exists is None: if user_exists is None:
add_to_newsletter(email) add_to_newsletter(email)
@@ -186,30 +184,21 @@ def add_to_newsletter(email):
Add a person to the newsletter database Add a person to the newsletter database
""" """
# Create connection to the database # Create connection to the database
db = Database() with Database() as db:
db.create_connection()
# Add the users email to the newsletter table # Add the users email to the newsletter table
db.execute(""" db.execute("""
INSERT INTO newsletter (email) INSERT INTO newsletter (email)
VALUES (?); VALUES (?);
""", (email,)) """, (email,))
db.close_connection()
def remove_from_newsletter(email): def remove_from_newsletter(email):
""" """
Remove a person from the newsletter database Remove a person from the newsletter database
""" """
# Create connection to the database # Create connection to the database
db = Database() with Database() as db:
db.create_connection()
# Remove the users email from the newsletter table # Remove the users email from the newsletter table
db.execute(""" db.execute("""
DELETE FROM newsletter DELETE FROM newsletter
WHERE email = ?; WHERE email = ?;
""", (email,)) """, (email,))
db.close_connection()