52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
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
|
|
if dbm.Outbound {
|
|
ium.Outbound = true
|
|
} else {
|
|
ium.Outbound = false
|
|
}
|
|
ium.Message = string(dbm.Data)
|
|
ium.Status = dbm.Status
|
|
ium.Contact = dbm.Contact
|
|
ium.CurrentLocation = dbm.CurrentLocation
|
|
ium.Messagetype = dbm.Type
|
|
ium.Appdata = dbm.Appdata
|
|
ium.FilePaths = dbm.FilePaths
|
|
return &ium
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
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
|
|
|
|
}
|