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