diff --git a/client/helpers/networkHelper.go b/client/helpers/networkHelper.go new file mode 100644 index 0000000..ab28b87 --- /dev/null +++ b/client/helpers/networkHelper.go @@ -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 +} diff --git a/doc/sq_srvinv03.puml b/doc/sq_srvinv03.puml index 90b0594..fd49b46 100644 --- a/doc/sq_srvinv03.puml +++ b/doc/sq_srvinv03.puml @@ -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 \ No newline at end of file diff --git a/doc/sq_srvinv04.puml b/doc/sq_srvinv04.puml index 460cbed..c84ea0a 100644 --- a/doc/sq_srvinv04.puml +++ b/doc/sq_srvinv04.puml @@ -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 \ No newline at end of file