message preview in progress
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ycc 2024-04-06 12:55:27 +02:00
parent 2513f0303a
commit 7fa997d443
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,15 @@
package helpers
import (
"forge.redroom.link/yves/meowlib/client"
)
func LoadMessagesHistory(peer_id int) ([]client.InternalUserMessage, string, error) {
id := client.GetConfig().GetIdentity()
peer := id.Peers[peer_id]
msgs, err := peer.LoadMessagesHistory(0, 0, 50)
if err != nil {
return nil, "LoadLastMessages: LoadMessagesHistory", err
}
return msgs, "", nil
}

View File

@ -224,6 +224,25 @@ func GetMessagesHistory(peer *Peer, inAppMsgCount int, lastDbId int, wantMore in
return messages, nil
}
// make an image from the files content (loads the first image, or build a more complex view)
func MessagePreview(msg *InternalUserMessage, password string) ([]byte, error) {
// get the hidden file name
if len(msg.FilePaths) == 0 {
return nil, nil
}
// get the hidden file
encData, err := os.ReadFile(msg.FilePaths[0])
if err != nil {
return nil, err
}
// decrypt the file
data, err := meowlib.SymDecrypt(password, encData)
if err != nil {
return nil, err
}
return data, nil
}
func getMessageCount(dbid string) (int, error) {
db, _ := sql.Open("sqlite3", filepath.Join(GetConfig().StoragePath, GetConfig().GetIdentity().Uuid, dbid+GetConfig().DbSuffix)) // Open the created SQLite File
defer db.Close()