This commit is contained in:
parent
2513f0303a
commit
7fa997d443
15
client/helpers/storageHelper.go
Normal file
15
client/helpers/storageHelper.go
Normal 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
|
||||||
|
}
|
@ -224,6 +224,25 @@ func GetMessagesHistory(peer *Peer, inAppMsgCount int, lastDbId int, wantMore in
|
|||||||
return messages, nil
|
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) {
|
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
|
db, _ := sql.Open("sqlite3", filepath.Join(GetConfig().StoragePath, GetConfig().GetIdentity().Uuid, dbid+GetConfig().DbSuffix)) // Open the created SQLite File
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
Loading…
Reference in New Issue
Block a user