meowlib/client/dbmessage.go

52 lines
1.2 KiB
Go
Raw Normal View History

2024-02-29 21:03:15 +01:00
package client
import (
"forge.redroom.link/yves/meowlib"
)
func DbMessageToInternalUserMessage(id int64, dbFile string, dbm *meowlib.DbMessage) *InternalUserMessage {
var ium InternalUserMessage
ium.Dbid = id
ium.Dbfile = dbFile
2024-03-02 10:45:05 +01:00
if dbm.Outbound {
ium.Outbound = true
} else {
ium.Outbound = false
}
2024-02-29 21:03:15 +01:00
ium.Message = string(dbm.Data)
2024-05-28 14:28:10 +02:00
ium.Status = dbm.Status
2024-02-29 21:03:15 +01:00
ium.Contact = dbm.Contact
ium.CurrentLocation = dbm.CurrentLocation
ium.Messagetype = dbm.Type
ium.Appdata = dbm.Appdata
ium.FilePaths = dbm.FilePaths
return &ium
}
2024-05-28 14:28:10 +02:00
func InternalUserMessageToDbMessage(ium *InternalUserMessage) *meowlib.DbMessage {
var dbm meowlib.DbMessage
dbm.Outbound = ium.Outbound
dbm.Type = ium.Messagetype
dbm.Data = []byte(ium.Message)
dbm.Appdata = ium.Appdata
dbm.Contact = ium.Contact
dbm.CurrentLocation = ium.CurrentLocation
dbm.Status = ium.Status
dbm.FilePaths = ium.FilePaths
return &dbm
}
2024-02-29 21:03:15 +01:00
func UserMessageToDbMessage(outbound bool, um *meowlib.UserMessage, filepaths []string) *meowlib.DbMessage {
var dbm meowlib.DbMessage
dbm.Outbound = outbound
dbm.Type = um.Type
dbm.Data = um.Data
dbm.Appdata = um.Appdata
dbm.Contact = um.Contact
dbm.CurrentLocation = um.CurrentLocation
dbm.Status = um.Status
dbm.FilePaths = filepaths
return &dbm
}