Redirect JoinServer Flow. Have Servers listen to QueueJoinServer Update. Handle delete contact flow for contact retry plugin

This commit is contained in:
Sarah Jamie Lewis 2023-08-29 12:16:49 -07:00
parent fb164b104b
commit 6d29ca322e
3 changed files with 11 additions and 3 deletions

View File

@ -179,6 +179,7 @@ func (cr *contactRetry) run() {
cr.bus.Subscribe(event.QueueJoinServer, cr.queue)
cr.bus.Subscribe(event.ProtocolEngineShutdown, cr.queue)
cr.bus.Subscribe(event.ProtocolEngineCreated, cr.queue)
cr.bus.Subscribe(event.DeleteContact, cr.queue)
for {
// Only attempt connection if both the ACN and the Protocol Engines are Online...
@ -228,6 +229,11 @@ func (cr *contactRetry) run() {
select {
case e := <-cr.queue.OutChan():
switch e.EventType {
case event.DeleteContact:
// this case covers both servers and peers (servers are peers, and go through the
// same delete conversation flow)
peer := e.Data[event.RemotePeer]
cr.authorizedPeers.Delete(peer)
case event.PeerStateChange:
state := connections.ConnectionStateToType()[e.Data[event.ConnectionState]]
peer := e.Data[event.RemotePeer]

View File

@ -30,7 +30,7 @@ func (f *Functionality) NotifySettingsUpdate(settings settings.GlobalSettings) {
}
func (f *Functionality) EventsToRegister() []event.Type {
return []event.Type{event.Heartbeat}
return []event.Type{event.Heartbeat, event.QueueJoinServer}
}
func (f *Functionality) ExperimentsToRegister() []string {
@ -45,6 +45,8 @@ func (f *Functionality) OnEvent(ev event.Event, profile peer.CwtchPeer) {
// TODO: do we need a secondary heartbeat for less common updates?
case event.Heartbeat:
f.PublishServerUpdate(profile)
case event.QueueJoinServer:
f.PublishServerUpdate(profile)
}
}
}

View File

@ -670,7 +670,7 @@ func (cp *cwtchPeer) ImportGroup(exportedInvite string) (int, error) {
cp.SetConversationAttribute(groupConversationID, attr.LocalScope.ConstructScopedZonedPath(attr.LegacyGroupZone.ConstructZonedPath(constants.GroupKey)), base64.StdEncoding.EncodeToString(gci.SharedKey))
cp.SetConversationAttribute(groupConversationID, attr.LocalScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants.Name)), gci.GroupName)
cp.eventBus.Publish(event.NewEvent(event.NewGroup, map[event.Field]string{event.ConversationID: strconv.Itoa(groupConversationID), event.GroupServer: gci.ServerHost, event.GroupInvite: exportedInvite, event.GroupName: gci.GroupName}))
cp.JoinServer(gci.ServerHost)
cp.QueueJoinServer(gci.ServerHost)
}
return groupConversationID, err
}
@ -993,7 +993,7 @@ func (cp *cwtchPeer) AddServer(serverSpecification string) (string, error) {
cp.SetConversationAttribute(conversationInfo.ID, attr.PublicScope.ConstructScopedZonedPath(attr.ServerKeyZone.ConstructZonedPath(k)), v)
}
cp.SetConversationAttribute(conversationInfo.ID, attr.PublicScope.ConstructScopedZonedPath(attr.ServerKeyZone.ConstructZonedPath(string(model.BundleType))), serverSpecification)
cp.JoinServer(onion)
cp.QueueJoinServer(onion)
return onion, err
}
return "", err