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"
|
||||||
"cwtch.im/cwtch/model/attr"
|
"cwtch.im/cwtch/model/attr"
|
||||||
"cwtch.im/cwtch/protocol/connections"
|
"cwtch.im/cwtch/protocol/connections"
|
||||||
groups2 "cwtch.im/cwtch/protocol/groups"
|
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"git.openprivacy.ca/flutter/libcwtch-go/constants"
|
"git.openprivacy.ca/flutter/libcwtch-go/constants"
|
||||||
"git.openprivacy.ca/flutter/libcwtch-go/features/groups"
|
"git.openprivacy.ca/flutter/libcwtch-go/features/groups"
|
||||||
"git.openprivacy.ca/openprivacy/log"
|
"git.openprivacy.ca/openprivacy/log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
import "cwtch.im/cwtch/event"
|
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])
|
uiManager.AddSendMessageError(e.Data[event.RemotePeer], e.Data[event.EventID], e.Data[event.Error])
|
||||||
*/
|
*/
|
||||||
case event.NewGroup:
|
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]
|
serializedInvite := ev.Event.Data[event.GroupInvite]
|
||||||
if strings.HasPrefix(serializedInvite, "torv3") {
|
if invite, err := model.ValidateInvite(serializedInvite); err == nil {
|
||||||
inviteJson, err := base64.StdEncoding.DecodeString(serializedInvite[5:])
|
groupPic := ph.GetProfilePic(invite.GroupID)
|
||||||
if err == nil {
|
ev.Event.Data["PicturePath"] = groupPic
|
||||||
json.Unmarshal(inviteJson, &invite)
|
} else {
|
||||||
groupPic := ph.GetProfilePic(invite.GroupID)
|
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)
|
||||||
ev.Event.Data["PicturePath"] = groupPic
|
return ""
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case event.PeerStateChange:
|
case event.PeerStateChange:
|
||||||
cxnState := connections.ConnectionStateToType()[ev.Event.Data[event.ConnectionState]]
|
cxnState := connections.ConnectionStateToType()[ev.Event.Data[event.ConnectionState]]
|
||||||
|
|
|
@ -284,7 +284,7 @@ func EnrichNewPeer(handle string, ph *PeerHelper, ev *EventProfileEnvelope) erro
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// could be a server?
|
// 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 errors.New("Not a peer or group")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue