Browse Source

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

pull/229/head
Dan Ballard Gogs 1 year ago
parent
commit
558df278d7
1 changed files with 11 additions and 2 deletions
  1. +11
    -2
      peer/cwtch_peer.go

+ 11
- 2
peer/cwtch_peer.go View File

@@ -44,6 +44,7 @@ type CwtchPeer interface {

JoinServer(string)
SendMessageToGroup(string, string) error
SendMessageToGroupTracked(string, string) (string, error)

GetProfile() *model.Profile

@@ -226,10 +227,18 @@ func (cp *cwtchPeer) JoinServer(onion string) {
}

// SendMessageToGroup attempts to sent the given message to the given group id.
// TODO: Deprecate in favour of SendMessageToGroupTracked
func (cp *cwtchPeer) SendMessageToGroup(groupid string, message string) error {
_, err := cp.SendMessageToGroupTracked(groupid, message)
return err
}

// SendMessageToGroup attempts to sent the given message to the given group id.
// It returns the signature of the message which can be used to identify it in any UX layer.
func (cp *cwtchPeer) SendMessageToGroupTracked(groupid string, message string) (string, error) {
group := cp.Profile.GetGroupByGroupID(groupid)
if group == nil {
return errors.New("invalid group id")
return "", errors.New("invalid group id")
}
ct, sig, err := cp.Profile.EncryptMessageToGroup(message, groupid)

@@ -237,7 +246,7 @@ func (cp *cwtchPeer) SendMessageToGroup(groupid string, message string) error {
cp.eventBus.Publish(event.NewEvent(event.SendMessageToGroup, map[event.Field]string{event.GroupServer: group.GroupServer, event.Ciphertext: string(ct), event.Signature: string(sig)}))
}

return err
return string(sig), err
}

func (cp *cwtchPeer) SendMessageToPeer(onion string, message string) string {


Loading…
Cancel
Save