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()
|
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
|
# 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
|
# Delete the conversation
|
||||||
db.session.delete(conversation)
|
db.session.delete(conversation)
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 131 KiB |
BIN
uploads/test.png
BIN
uploads/test.png
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
Reference in New Issue
Block a user