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

View File

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

View File

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

View File

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

View File

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