Browse Source

Merge branch 'postalpha' of cwtch.im/cwtch into master

postalpha
Dan Ballard Gogs 1 year ago
parent
commit
fca4fe17eb
2 changed files with 13 additions and 3 deletions
  1. +7
    -0
      event/common.go
  2. +6
    -3
      protocol/connections/engine.go

+ 7
- 0
event/common.go View File

@@ -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")



+ 6
- 3
protocol/connections/engine.go View File

@@ -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…
Cancel
Save