forked from cwtch.im/cwtch
Cutting cruft from import group
This commit is contained in:
parent
de32784286
commit
3f6623bf42
|
@ -22,7 +22,7 @@ const (
|
||||||
// TimestampReceived [eg time.Now().Format(time.RFC3339Nano)]
|
// TimestampReceived [eg time.Now().Format(time.RFC3339Nano)]
|
||||||
// RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
|
// RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
|
||||||
// GroupInvite: [eg "torv3....."]
|
// GroupInvite: [eg "torv3....."]
|
||||||
NewGroupInvite = Type("NewGroupInvite")
|
NewGroupInvite = Type("NewGroupInvite")
|
||||||
|
|
||||||
SendMessageToGroup = Type("SendMessagetoGroup")
|
SendMessageToGroup = Type("SendMessagetoGroup")
|
||||||
EncryptedGroupMessage = Type("EncryptedGroupMessage")
|
EncryptedGroupMessage = Type("EncryptedGroupMessage")
|
||||||
|
|
|
@ -11,9 +11,7 @@ import (
|
||||||
"git.openprivacy.ca/openprivacy/libricochet-go/connectivity"
|
"git.openprivacy.ca/openprivacy/libricochet-go/connectivity"
|
||||||
"git.openprivacy.ca/openprivacy/libricochet-go/identity"
|
"git.openprivacy.ca/openprivacy/libricochet-go/identity"
|
||||||
"git.openprivacy.ca/openprivacy/libricochet-go/log"
|
"git.openprivacy.ca/openprivacy/libricochet-go/log"
|
||||||
"git.openprivacy.ca/openprivacy/libricochet-go/utils"
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"golang.org/x/crypto/ed25519"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -114,22 +112,15 @@ func (cp *cwtchPeer) ImportGroup(exportedInvite string) (groupID string, err err
|
||||||
cpp := &protocol.CwtchPeerPacket{}
|
cpp := &protocol.CwtchPeerPacket{}
|
||||||
err = proto.Unmarshal(data, cpp)
|
err = proto.Unmarshal(data, cpp)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
pk, err := base64.StdEncoding.DecodeString(exportedInvite[5 : 5+44])
|
jsobj, err := json.Marshal(cpp.GetGroupChatInvite())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
edpk := ed25519.PublicKey(pk)
|
cp.eventBus.Publish(event.NewEvent(event.NewGroupInvite, map[event.Field]string{
|
||||||
onion := utils.GetTorV3Hostname(edpk)
|
event.GroupInvite: string(jsobj),
|
||||||
cp.Profile.AddContact(onion, &model.PublicProfile{Name: "", Ed25519PublicKey: edpk, Trusted: true, Blocked: false, Onion: onion})
|
}))
|
||||||
cp.Profile.ProcessInvite(cpp.GetGroupChatInvite(), onion)
|
} else {
|
||||||
jsobj, err := json.Marshal(cpp.GetGroupChatInvite())
|
log.Errorf("error serializing group: %v", err)
|
||||||
if err == nil {
|
|
||||||
cp.eventBus.Publish(event.NewEvent(event.NewGroupInvite, map[event.Field]string{
|
|
||||||
event.GroupInvite: string(jsobj),
|
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
log.Errorf("error serializing group: %v", err)
|
|
||||||
}
|
|
||||||
return cpp.GroupChatInvite.GetGroupName(), nil
|
|
||||||
}
|
}
|
||||||
|
return cpp.GroupChatInvite.GetGroupName(), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue