UPDATE: Improved chat functionality and cleaned up code

This commit is contained in:
white
2025-03-02 15:58:25 +00:00
parent b62ebf584d
commit fc934a57ff
3 changed files with 6 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
from flask import Blueprint, jsonify, session
from flask import Blueprint, jsonify
from database.database import Database
from .socket import socketio
from flask_socketio import emit, join_room, leave_room
@@ -11,8 +11,6 @@ redis_url = "redis://redis:6379/1"
r = redis.from_url(redis_url, decode_responses=True)
chat_bp = Blueprint("chat", __name__)
#NOTE: <---------------------- ROUTES NEEDS TO BE CHANGED TO VIDEO OR DELETED AS DEEMED APPROPRIATE ---------------------->
@socketio.on("connect")
def handle_connection() -> None:
"""
@@ -87,7 +85,6 @@ def get_past_chat(stream_id: int):
ORDER BY time_sent ASC
LIMIT 50;
""", (stream_id,))
db.close_connection()
# Create JSON output of chat_history to pass through NGINX proxy
@@ -145,6 +142,7 @@ def update_viewers(user_id, num_viewers):
WHERE user_id = ?;
""", (num_viewers, user_id))
db.close_connection
#TODO: Make sure that users entry within Redis is removed if they disconnect from socket
def add_favourability_entry(user_id, stream_id):
"""

View File

@@ -1,4 +1,4 @@
from flask import redirect, url_for, request, g, session
from flask import redirect, g, session
from functools import wraps
import logging
from os import getenv

View File

@@ -16,6 +16,9 @@ url = getenv("HOMEPAGE_URL")
def init_oauth(app):
"""
Initialise the OAuth functionality.
"""
oauth = OAuth(app)
global google
google = oauth.register(