diff --git a/routes/__pycache__/conversations.cpython-313.pyc b/routes/__pycache__/conversations.cpython-313.pyc index 7b749cf..5f57099 100644 Binary files a/routes/__pycache__/conversations.cpython-313.pyc and b/routes/__pycache__/conversations.cpython-313.pyc differ diff --git a/routes/__pycache__/main.cpython-313.pyc b/routes/__pycache__/main.cpython-313.pyc index 7f90ded..c453e41 100644 Binary files a/routes/__pycache__/main.cpython-313.pyc and b/routes/__pycache__/main.cpython-313.pyc differ diff --git a/routes/conversations.py b/routes/conversations.py index c07de7d..4f6acea 100644 --- a/routes/conversations.py +++ b/routes/conversations.py @@ -328,8 +328,21 @@ def delete_conversation(conversation_id): ) db.session.commit() + # Get all messages in the conversation + messages = Message.query.filter_by(conversation_id=conversation_id).all() + + # Delete attachments and their files first + for message in messages: + for attachment in message.attachments: + # Delete the physical file + if os.path.exists(attachment.path): + os.remove(attachment.path) + # Delete the attachment record + db.session.delete(attachment) + # Delete all messages in the conversation - Message.query.filter_by(conversation_id=conversation_id).delete() + for message in messages: + db.session.delete(message) # Delete the conversation db.session.delete(conversation) diff --git a/uploads/Screenshot_2025-05-27_103137.png b/uploads/Screenshot_2025-05-27_103137.png deleted file mode 100644 index 11f9e13..0000000 Binary files a/uploads/Screenshot_2025-05-27_103137.png and /dev/null differ diff --git a/uploads/test.png b/uploads/test.png deleted file mode 100644 index eb5fc48..0000000 Binary files a/uploads/test.png and /dev/null differ