mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
adjusted message handler
This commit is contained in:
parent
c33d23f326
commit
ff624a4c9a
1 changed files with 4 additions and 1 deletions
|
@ -24,13 +24,16 @@ class DatabaseManagerAttachments(DatabaseManager):
|
|||
)
|
||||
session.add(attachment)
|
||||
session.flush() # Ensure the attachment is persisted and has an ID
|
||||
self.log(f"Added attachment to database: {attachment.name}")
|
||||
else:
|
||||
attachment = existing_attachment
|
||||
self.log(f"Attachment {attachment.name} already exists in database")
|
||||
|
||||
# Link the message and the attachment through MessageAttachment
|
||||
link = MessageAttachment(message=message, attachment=attachment)
|
||||
self.log(f"Added attachment to database: {attachment.name}")
|
||||
session.add(link)
|
||||
self.log(f"Linked message with attachment: {attachment.name}")
|
||||
|
||||
return attachment
|
||||
|
||||
def get_attachments_by_message_id(self, message_id):
|
||||
|
|
Loading…
Reference in a new issue