corrected container and other errors

This commit is contained in:
Josako
2024-06-28 14:40:13 +02:00
parent 7a1b51dd0c
commit 9187947f68
105 changed files with 16882 additions and 2279 deletions

View File

@@ -4,6 +4,7 @@ from flask_jwt_extended import create_access_token, get_jwt_identity, verify_jwt
from flask_socketio import emit, disconnect
from flask import current_app, request, session
from sqlalchemy.exc import SQLAlchemyError
from datetime import datetime, timedelta
from common.extensions import socketio, kms_client, db
from common.models.user import Tenant
@@ -35,6 +36,8 @@ def handle_connect():
if 'session_id' not in session:
session['session_id'] = str(uuid.uuid4())
session['last_activity'] = datetime.now()
# Communicate connection to client
current_app.logger.debug(f'SocketIO: Connection handling sending status to client for tenant {tenant_id}')
emit('connect', {'status': 'Connected', 'tenant_id': tenant_id})
@@ -53,11 +56,21 @@ def handle_disconnect():
current_app.logger.debug('SocketIO: Client disconnected')
@socketio.on('heartbeat')
def handle_heartbeat():
current_app.logger.debug('SocketIO: Heartbeat received')
last_activity = session.get('last_activity')
if datetime.now() - last_activity > current_app.config.get('SOCKETIO_MAX_IDLE_TIME'):
current_app.logger.debug('SocketIO: Heartbeat timed out, connection closed')
disconnect()
@socketio.on('user_message')
def handle_message(data):
try:
current_app.logger.debug(f"SocketIO: Message handling received message from tenant {data['tenantId']}: "
f"{data['message']} with token {data['token']}")
session['last_activity'] = datetime.now()
current_tenant_id = validate_incoming_data(data)