Btter version for convos

This commit is contained in:
2025-05-31 13:02:56 +02:00
parent 4bd5180b87
commit 4e6bf7b03c
5 changed files with 14 additions and 1 deletions

View File

@@ -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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB