From 66927c42985c183515f58fa90358f79a90fdb029 Mon Sep 17 00:00:00 2001 From: ycc Date: Sun, 18 Dec 2022 20:37:26 +0100 Subject: [PATCH] refactor #2 --- client/message.go | 1 - client/server.go | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/client/message.go b/client/message.go index 22ca8f4..d68caf3 100644 --- a/client/message.go +++ b/client/message.go @@ -37,7 +37,6 @@ func ProcessOutboundTextMessage(peer *Peer, text string, srv *InternalServer) ([ } // Creating Server message for transporting the user message toServerMessage := srv.BuildToServerMessageFromUserMessage(packedMsg) - return ProcessOutboundMessage(toServerMessage, srv) } diff --git a/client/server.go b/client/server.go index c07f3ff..aa2092a 100644 --- a/client/server.go +++ b/client/server.go @@ -64,13 +64,19 @@ func (ints *InternalServer) AsymDecryptMessage(Message []byte, Signature []byte) } // Creates a basic message to server from a single packed user message and returns it as protobuf serialized byte array -func (ints *InternalServer) BuildMessageSendingMessage(usermsg *meowlib.PackedUserMessage) ([]byte, error) { +func (ints *InternalServer) BuildToServerMessageFromUserMessage(usermsg *meowlib.PackedUserMessage) *meowlib.ToServerMessage { var msg meowlib.ToServerMessage msg.Uuid = uuid.New().String() msg.Type = "1" msg.From = ints.Me.Public msg.Messages = append(msg.Messages, usermsg) - out, err := proto.Marshal(&msg) + return &msg +} + +// Creates a basic message to server from a single packed user message and returns it as protobuf serialized byte array +func (ints *InternalServer) BuildMessageSendingMessage(usermsg *meowlib.PackedUserMessage) ([]byte, error) { + msg := ints.BuildToServerMessageFromUserMessage(usermsg) + out, err := proto.Marshal(msg) if err != nil { return nil, err }