diff --git a/event/common.go b/event/common.go index a9a8ccd..9825b96 100644 --- a/event/common.go +++ b/event/common.go @@ -57,6 +57,7 @@ const ( // GroupID AcceptGroupInvite = Type("AcceptGroupInvite") + RejectGroupInvite = Type("RejectGroupInvite") SendMessageToGroup = Type("SendMessagetoGroup") diff --git a/peer/cwtch_peer.go b/peer/cwtch_peer.go index 0151357..f136b87 100644 --- a/peer/cwtch_peer.go +++ b/peer/cwtch_peer.go @@ -563,6 +563,7 @@ func (cp *cwtchPeer) RejectInvite(groupID string) { cp.mutex.Lock() defer cp.mutex.Unlock() cp.Profile.RejectInvite(groupID) + cp.eventBus.Publish(event.NewEvent(event.RejectGroupInvite, map[event.Field]string{event.GroupID: groupID})) } // Listen makes the peer open a listening port to accept incoming connections (and be detactably online) diff --git a/storage/v1/profile_store.go b/storage/v1/profile_store.go index a6b89bb..e4f358b 100644 --- a/storage/v1/profile_store.go +++ b/storage/v1/profile_store.go @@ -75,6 +75,7 @@ func (ps *ProfileStoreV1) initProfileWriterStore() { ps.eventManager.Subscribe(event.SetPeerAttribute, ps.queue) ps.eventManager.Subscribe(event.SetGroupAttribute, ps.queue) ps.eventManager.Subscribe(event.AcceptGroupInvite, ps.queue) + ps.eventManager.Subscribe(event.RejectGroupInvite, ps.queue) ps.eventManager.Subscribe(event.NewGroupInvite, ps.queue) ps.eventManager.Subscribe(event.NewMessageFromGroup, ps.queue) ps.eventManager.Subscribe(event.SendMessageToPeer, ps.queue) @@ -373,6 +374,9 @@ func (ps *ProfileStoreV1) eventHandler() { } else { log.Errorf("error accepting group invite") } + case event.RejectGroupInvite: + ps.profile.RejectInvite(ev.Data[event.GroupID]) + ps.save() case event.NewGroupInvite: gid, _, err := ps.profile.ProcessInvite(ev.Data[event.GroupInvite], ev.Data[event.RemotePeer]) if err == nil {