From 711e46ce109e9d0ec1ecff2265aec6bdffdc10ce Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 20 Feb 2019 12:58:05 -0800 Subject: [PATCH] Adding Error Tracking to Group Sends --- event/common.go | 7 +++++++ protocol/connections/engine.go | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/event/common.go b/event/common.go index 8e93783..f658788 100644 --- a/event/common.go +++ b/event/common.go @@ -31,6 +31,13 @@ const ( EncryptedGroupMessage = Type("EncryptedGroupMessage") NewMessageFromGroup = Type("NewMessageFromGroup") + // an error was encountered trying to send a particular message to a group + // attributes: + // GroupServer: The server the message was sent to + // Signature: The signature of the message that failed to send + // Error: string describing the error + SendMessageToGroupError = Type("SendMessageToGroupError") + SendMessageToPeer = Type("SendMessageToPeer") NewMessageFromPeer = Type("NewMessageFromPeer") diff --git a/protocol/connections/engine.go b/protocol/connections/engine.go index 795e393..bd4e546 100644 --- a/protocol/connections/engine.go +++ b/protocol/connections/engine.go @@ -213,17 +213,20 @@ func (e *Engine) JoinServer(onion string) { } // SendMessageToGroup attempts to sent the given message to the given group id. -func (e *Engine) SendMessageToGroup(server string, ct []byte, sig []byte) error { +func (e *Engine) SendMessageToGroup(server string, ct []byte, sig []byte) { psc := e.connectionsManager.GetPeerServerConnectionForOnion(server) if psc == nil { - return errors.New("could not find server connection to send message to") + e.eventManager.Publish(event.NewEvent(event.SendMessageToGroupError, map[event.Field]string{event.GroupServer: server, event.Signature: string(sig), event.Error: "server is offline or the connection has yet to finalize"})) } gm := &protocol.GroupMessage{ Ciphertext: ct, Signature: sig, } err := psc.SendGroupMessage(gm) - return err + + if err != nil { + e.eventManager.Publish(event.NewEvent(event.SendMessageToGroupError, map[event.Field]string{event.GroupServer: server, event.Signature: string(sig), event.Error: err.Error()})) + } } // GetPeers returns a list of peer connections.