forked from cwtch.im/cwtch
Redirect JoinServer Flow. Have Servers listen to QueueJoinServer Update. Handle delete contact flow for contact retry plugin
This commit is contained in:
parent
fb164b104b
commit
6d29ca322e
|
@ -179,6 +179,7 @@ func (cr *contactRetry) run() {
|
||||||
cr.bus.Subscribe(event.QueueJoinServer, cr.queue)
|
cr.bus.Subscribe(event.QueueJoinServer, cr.queue)
|
||||||
cr.bus.Subscribe(event.ProtocolEngineShutdown, cr.queue)
|
cr.bus.Subscribe(event.ProtocolEngineShutdown, cr.queue)
|
||||||
cr.bus.Subscribe(event.ProtocolEngineCreated, cr.queue)
|
cr.bus.Subscribe(event.ProtocolEngineCreated, cr.queue)
|
||||||
|
cr.bus.Subscribe(event.DeleteContact, cr.queue)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
// Only attempt connection if both the ACN and the Protocol Engines are Online...
|
// Only attempt connection if both the ACN and the Protocol Engines are Online...
|
||||||
|
@ -228,6 +229,11 @@ func (cr *contactRetry) run() {
|
||||||
select {
|
select {
|
||||||
case e := <-cr.queue.OutChan():
|
case e := <-cr.queue.OutChan():
|
||||||
switch e.EventType {
|
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:
|
case event.PeerStateChange:
|
||||||
state := connections.ConnectionStateToType()[e.Data[event.ConnectionState]]
|
state := connections.ConnectionStateToType()[e.Data[event.ConnectionState]]
|
||||||
peer := e.Data[event.RemotePeer]
|
peer := e.Data[event.RemotePeer]
|
||||||
|
|
|
@ -30,7 +30,7 @@ func (f *Functionality) NotifySettingsUpdate(settings settings.GlobalSettings) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Functionality) EventsToRegister() []event.Type {
|
func (f *Functionality) EventsToRegister() []event.Type {
|
||||||
return []event.Type{event.Heartbeat}
|
return []event.Type{event.Heartbeat, event.QueueJoinServer}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Functionality) ExperimentsToRegister() []string {
|
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?
|
// TODO: do we need a secondary heartbeat for less common updates?
|
||||||
case event.Heartbeat:
|
case event.Heartbeat:
|
||||||
f.PublishServerUpdate(profile)
|
f.PublishServerUpdate(profile)
|
||||||
|
case event.QueueJoinServer:
|
||||||
|
f.PublishServerUpdate(profile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.LegacyGroupZone.ConstructZonedPath(constants.GroupKey)), base64.StdEncoding.EncodeToString(gci.SharedKey))
|
||||||
cp.SetConversationAttribute(groupConversationID, attr.LocalScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants.Name)), gci.GroupName)
|
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.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
|
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(k)), v)
|
||||||
}
|
}
|
||||||
cp.SetConversationAttribute(conversationInfo.ID, attr.PublicScope.ConstructScopedZonedPath(attr.ServerKeyZone.ConstructZonedPath(string(model.BundleType))), serverSpecification)
|
cp.SetConversationAttribute(conversationInfo.ID, attr.PublicScope.ConstructScopedZonedPath(attr.ServerKeyZone.ConstructZonedPath(string(model.BundleType))), serverSpecification)
|
||||||
cp.JoinServer(onion)
|
cp.QueueJoinServer(onion)
|
||||||
return onion, err
|
return onion, err
|
||||||
}
|
}
|
||||||
return "", err
|
return "", err
|
||||||
|
|
Loading…
Reference in New Issue