diff --git a/event/common.go b/event/common.go index d508279..c98bc29 100644 --- a/event/common.go +++ b/event/common.go @@ -16,6 +16,12 @@ const ( ProtocolEngineStopped = Type("ProtocolEngineStopped") InvitePeerToGroup = Type("InvitePeerToGroup") + + // a group invite has been received from a remote peer + // attributes: + // TimestampReceived [eg time.Now().Format(time.RFC3339Nano)] + // RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"] + // GroupInvite: [eg "torv3....."] NewGroupInvite = Type("NewGroupInvite") SendMessageToGroup = Type("SendMessagetoGroup") diff --git a/model/profile.go b/model/profile.go index 7a7b965..ef2e246 100644 --- a/model/profile.go +++ b/model/profile.go @@ -49,7 +49,9 @@ func generateRandomID() string { } func (p *PublicProfile) init() { - p.Attributes = make(map[string]string) + if p.Attributes == nil { + p.Attributes = make(map[string]string) + } p.LocalID = generateRandomID() } diff --git a/peer/cwtch_peer.go b/peer/cwtch_peer.go index ea8053e..53f4a40 100644 --- a/peer/cwtch_peer.go +++ b/peer/cwtch_peer.go @@ -184,8 +184,7 @@ func (cp *cwtchPeer) GetGroup(groupID string) *model.Group { } func (cp *cwtchPeer) AddContact(nick, onion string, publickey []byte, trusted bool) { - pp := &model.PublicProfile{Name: nick, Ed25519PublicKey: publickey, Trusted: trusted, Blocked: false, Onion: onion, Attributes: map[string]string{"name": nick}} - cp.GetProfile().Contacts[onion] = pp + pp := &model.PublicProfile{Name: nick, Ed25519PublicKey: publickey, Trusted: trusted, Blocked: false, Onion: onion, Attributes: map[string]string{"nick": nick}} cp.Profile.AddContact(onion, pp) pd, _ := json.Marshal(pp) cp.eventBus.Publish(event.NewEvent(event.PeerCreated, map[event.Field]string{