Merge branch 'postalpha' of cwtch.im/cwtch into master
This commit is contained in:
commit
558df278d7
|
@ -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 {
|
||||
|
|
Ładowanie…
Reference in New Issue