forked from cwtch.im/cwtch
Adding Error Tracking to Group Sends
This commit is contained in:
parent
600e1b31e6
commit
711e46ce10
|
@ -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")
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue