Http helper function added
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ycc 2024-03-25 13:24:43 +01:00
parent f80411bf21
commit 6867086c4f
3 changed files with 32 additions and 2 deletions

View File

@ -0,0 +1,30 @@
package helpers
import (
"forge.redroom.link/yves/meowlib"
"forge.redroom.link/yves/meowlib/client"
)
func HttpSendMessage(serverUid string, message []byte) ([]byte, error) {
id := client.GetConfig().GetIdentity()
srv, err := id.MessageServers.LoadServer(serverUid)
if err != nil {
return nil, err
}
// gettig server Public key if missing
if srv.PublicKey == "" {
srvdata, err := meowlib.HttpGetId(srv.Url)
if err != nil {
return nil, err
}
//print(srvdata["publicKey"])
srv.PublicKey = srvdata["publicKey"]
id.MessageServers.StoreServer(srv)
}
response, err := meowlib.HttpPostMessage(srv.Url, message)
if err != nil {
return nil, err
}
return response, nil
}

View File

@ -8,5 +8,5 @@ NativeLib -> Bastet : invitationGetMessage
Bastet -> Server : send accept message
Server -> Redis : store accept message
Server -> Bastet : accept message ok
Bastet -> User : msg sent
Bastet -> User : accept msg sent
@enduml

View File

@ -5,5 +5,5 @@ NativeLib -> Server : get new messages
Server -> NativeLib : send invitation message
Server -> Redis : store accept message
Server -> Bastet : accept message ok
Bastet -> User : msg sent
Bastet -> User : invitation sent is accepted
@enduml