From 99a9aa14afe4e6255c02218cef929149063bc7b2 Mon Sep 17 00:00:00 2001 From: ycc Date: Fri, 5 Apr 2024 23:07:23 +0200 Subject: [PATCH] store securefiles in messages and not filenames --- client/messagestorage.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/messagestorage.go b/client/messagestorage.go index 5c5caba..640f426 100644 --- a/client/messagestorage.go +++ b/client/messagestorage.go @@ -43,6 +43,7 @@ func StoreMessage(peer *Peer, usermessage *meowlib.UserMessage, filenames []stri db, _ := sql.Open("sqlite3", filepath.Join(cfg.StoragePath, identity.Uuid, dbid+GetConfig().DbSuffix)) // Open the created SQLite File defer db.Close() // Detach Files + hiddenFilenames := []string{} if len(usermessage.Files) > 0 { for _, f := range usermessage.Files { hiddenFilename := uuid.NewString() @@ -58,7 +59,7 @@ func StoreMessage(peer *Peer, usermessage *meowlib.UserMessage, filenames []stri } } os.WriteFile(filepath.Join(cfg.StoragePath, identity.Uuid, "securefiles", hiddenFilename), encData, 0600) - + hiddenFilenames = append(hiddenFilenames, filepath.Join(cfg.StoragePath, identity.Uuid, "securefiles", hiddenFilename)) // replace f.Data by uuid filename f.Data = []byte(filepath.Join(cfg.StoragePath, identity.Uuid, "securefiles", hiddenFilename)) } @@ -68,7 +69,7 @@ func StoreMessage(peer *Peer, usermessage *meowlib.UserMessage, filenames []stri outbound = false } // Convert UserMessage to DbMessage - dbm := UserMessageToDbMessage(outbound, usermessage, filenames) + dbm := UserMessageToDbMessage(outbound, usermessage, hiddenFilenames) // Encrypt message out, err := proto.Marshal(dbm) if err != nil {