This commit is contained in:
2025-10-22 22:07:52 +03:00
Unverified
parent a95efcdcf8
commit 87f3ddc2f0
5 changed files with 9 additions and 17 deletions
+2 -2
View File
@@ -18,7 +18,7 @@ logger = logging.getLogger("uvicorn.error")
async def lifespan(app: FastAPI): async def lifespan(app: FastAPI):
# Startup - run migration in separate process to avoid logging interference # Startup - run migration in separate process to avoid logging interference
try: try:
print("Starting database migration check...") logger.info("Starting database migration check...")
# Run migration in a separate process # Run migration in a separate process
subprocess.run( subprocess.run(
[ [
@@ -29,7 +29,7 @@ async def lifespan(app: FastAPI):
cwd=os.path.dirname(os.path.abspath(__file__)) cwd=os.path.dirname(os.path.abspath(__file__))
) )
except Exception as e: except Exception as e:
print(f"Failed to run database migrations: {e}") logger.error(f"Failed to run database migrations: {e}")
raise raise
try: try:
+7 -7
View File
@@ -3,6 +3,7 @@ import re
from fastapi import APIRouter, Depends, HTTPException, UploadFile, File from fastapi import APIRouter, Depends, HTTPException, UploadFile, File
from fastapi.responses import FileResponse from fastapi.responses import FileResponse
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from sqlalchemy import inspect, text
from PIL import Image from PIL import Image
import os import os
import uuid import uuid
@@ -13,6 +14,7 @@ from models import User, UpdateBioRequest, UserProfileResponse
from pydantic import BaseModel from pydantic import BaseModel
from validation import is_valid_username, is_valid_display_name from validation import is_valid_username, is_valid_display_name
from similarity import is_user_similar_to_verified from similarity import is_user_similar_to_verified
from messaging import messagingManager
router = APIRouter() router = APIRouter()
@@ -363,11 +365,10 @@ async def suspend_user(
# Send WebSocket suspension message # Send WebSocket suspension message
try: try:
from .messaging import messagingManager
await messagingManager.send_suspension_to_user(user_id, request.reason) await messagingManager.send_suspension_to_user(user_id, request.reason)
except Exception as e: except Exception as e:
# Log error but don't fail the request # Log error but don't fail the request
print(f"Failed to send suspension WebSocket message: {e}") pass
return { return {
"status": "success", "status": "success",
@@ -444,13 +445,13 @@ async def delete_user(
if os.path.exists(filepath): if os.path.exists(filepath):
os.remove(filepath) os.remove(filepath)
except Exception as e: except Exception as e:
print(f"Failed to delete profile picture: {e}") # Log error but don't fail the request
pass
# Dynamic deletion of all non-whitelist data # Dynamic deletion of all non-whitelist data
WHITELIST_TABLES = {"message", "dm_envelope", "reaction", "dm_reaction", "message_file", "dm_file"} WHITELIST_TABLES = {"message", "dm_envelope", "reaction", "dm_reaction", "message_file", "dm_file"}
try: try:
from sqlalchemy import inspect, text
inspector = inspect(db.bind) inspector = inspect(db.bind)
all_tables = inspector.get_table_names() all_tables = inspector.get_table_names()
@@ -468,17 +469,16 @@ async def delete_user(
db.commit() db.commit()
except Exception as e: except Exception as e:
print(f"Failed to delete user data: {e}") # Log error and rollback
db.rollback() db.rollback()
raise HTTPException(status_code=500, detail="Failed to delete user data") raise HTTPException(status_code=500, detail="Failed to delete user data")
# Send WebSocket deletion message # Send WebSocket deletion message
try: try:
from .messaging import messagingManager
await messagingManager.send_deletion_to_user(user_id) await messagingManager.send_deletion_to_user(user_id)
except Exception as e: except Exception as e:
# Log error but don't fail the request # Log error but don't fail the request
print(f"Failed to send deletion WebSocket message: {e}") pass
return { return {
"status": "success", "status": "success",
-1
View File
@@ -69,7 +69,6 @@ export function useDM() {
try { try {
lastPlaintext = (JSON.parse(await decryptDm(lastMessage, publicKey)) as DmEncryptedJSON).data.content; lastPlaintext = (JSON.parse(await decryptDm(lastMessage, publicKey)) as DmEncryptedJSON).data.content;
console.log(lastPlaintext);
} catch (error) { } catch (error) {
console.error("Failed to decrypt last message:", error); console.error("Failed to decrypt last message:", error);
} }
-4
View File
@@ -266,8 +266,6 @@ export const useAppState = create<AppState>((set, get) => ({
credentials: token credentials: token
}, },
data: {} data: {}
}).then(() => {
console.log("Ping succeeded")
}) })
} catch {} } catch {}
}, },
@@ -342,8 +340,6 @@ export const useAppState = create<AppState>((set, get) => ({
credentials: token credentials: token
}, },
data: {} data: {}
}).then(() => {
console.log("Ping succeeded")
}) })
} catch {} } catch {}
@@ -193,12 +193,9 @@ export function Message({ message, isAuthor, onContextMenu, onReactionClick, isD
useEffect(() => { useEffect(() => {
if (isDm && message.files) { if (isDm && message.files) {
message.files.forEach(async (file) => { message.files.forEach(async (file) => {
console.log(file);
const isImage = /\.(png|jpg|jpeg|gif|webp)$/i.test(file.name || ""); const isImage = /\.(png|jpg|jpeg|gif|webp)$/i.test(file.name || "");
if (isImage && file.encrypted && !decryptedFiles.has(file.path)) { if (isImage && file.encrypted && !decryptedFiles.has(file.path)) {
console.log("Decrypting...");
const decryptedUrl = await decryptFile(file); const decryptedUrl = await decryptFile(file);
console.log(decryptedUrl);
if (decryptedUrl) { if (decryptedUrl) {
updateDecryptedFiles(draft => { updateDecryptedFiles(draft => {
draft.set(file.path, decryptedUrl); draft.set(file.path, decryptedUrl);