Merge pull request 'Using new group API to avoid replicated code' (#41) from groups into trunk
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Reviewed-on: #41
This commit is contained in:
commit
83c3ad21c3
|
@ -6,14 +6,11 @@ import (
|
|||
"cwtch.im/cwtch/model"
|
||||
"cwtch.im/cwtch/model/attr"
|
||||
"cwtch.im/cwtch/protocol/connections"
|
||||
groups2 "cwtch.im/cwtch/protocol/groups"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"git.openprivacy.ca/flutter/libcwtch-go/constants"
|
||||
"git.openprivacy.ca/flutter/libcwtch-go/features/groups"
|
||||
"git.openprivacy.ca/openprivacy/log"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
import "cwtch.im/cwtch/event"
|
||||
|
||||
|
@ -269,15 +266,15 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
|||
uiManager.AddSendMessageError(e.Data[event.RemotePeer], e.Data[event.EventID], e.Data[event.Error])
|
||||
*/
|
||||
case event.NewGroup:
|
||||
var invite = groups2.GroupInvite{}
|
||||
// This event should only happen after we have validated the invite, as such the error
|
||||
// condition *should* never happen.
|
||||
serializedInvite := ev.Event.Data[event.GroupInvite]
|
||||
if strings.HasPrefix(serializedInvite, "torv3") {
|
||||
inviteJson, err := base64.StdEncoding.DecodeString(serializedInvite[5:])
|
||||
if err == nil {
|
||||
json.Unmarshal(inviteJson, &invite)
|
||||
groupPic := ph.GetProfilePic(invite.GroupID)
|
||||
ev.Event.Data["PicturePath"] = groupPic
|
||||
}
|
||||
if invite, err := model.ValidateInvite(serializedInvite); err == nil {
|
||||
groupPic := ph.GetProfilePic(invite.GroupID)
|
||||
ev.Event.Data["PicturePath"] = groupPic
|
||||
} else {
|
||||
log.Errorf("received a new group event which contained an invalid invite %v. this should never happen and likely means there is a bug in cwtch. Please file a ticket @ https://git.openprivcy.ca/cwtch.im/cwtch", err)
|
||||
return ""
|
||||
}
|
||||
case event.PeerStateChange:
|
||||
cxnState := connections.ConnectionStateToType()[ev.Event.Data[event.ConnectionState]]
|
||||
|
|
|
@ -284,7 +284,7 @@ func EnrichNewPeer(handle string, ph *PeerHelper, ev *EventProfileEnvelope) erro
|
|||
}
|
||||
} else {
|
||||
// could be a server?
|
||||
log.Errorf("sorry, unable to handle AddContact(%v)", handle)
|
||||
log.Infof("sorry, unable to handle AddContact(%v)", handle)
|
||||
return errors.New("Not a peer or group")
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue