Btter version for convos
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user