Minimize Event Noise for Server Updates / Handle Blocking Flow for ContactRetry plugin
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
Sarah Jamie Lewis 2023-08-29 12:20:08 -07:00
parent 6d29ca322e
commit 407902b8ee
2 changed files with 11 additions and 4 deletions

View File

@ -180,7 +180,7 @@ func (cr *contactRetry) run() {
cr.bus.Subscribe(event.ProtocolEngineShutdown, cr.queue)
cr.bus.Subscribe(event.ProtocolEngineCreated, cr.queue)
cr.bus.Subscribe(event.DeleteContact, cr.queue)
cr.bus.Subscribe(event.UpdateConversationAuthorization, cr.queue)
for {
// Only attempt connection if both the ACN and the Protocol Engines are Online...
log.Debugf("restartFlow checking state")
@ -234,6 +234,14 @@ func (cr *contactRetry) run() {
// same delete conversation flow)
peer := e.Data[event.RemotePeer]
cr.authorizedPeers.Delete(peer)
case event.UpdateConversationAuthorization:
// if we update the conversation authorization then we need to check if
// we need to remove blocked conversations from the regular flow.
peer := e.Data[event.RemotePeer]
blocked := e.Data[event.Blocked]
if blocked == "true" {
cr.authorizedPeers.Delete(peer)
}
case event.PeerStateChange:
state := connections.ConnectionStateToType()[e.Data[event.ConnectionState]]
peer := e.Data[event.RemotePeer]

View File

@ -42,9 +42,8 @@ func (f *Functionality) OnEvent(ev event.Event, profile peer.CwtchPeer) {
if profile.IsFeatureEnabled(constants.GroupsExperiment) {
switch ev.EventType {
// keep the UI in sync with the current backend server updates...
// TODO: do we need a secondary heartbeat for less common updates?
case event.Heartbeat:
f.PublishServerUpdate(profile)
// queue join server gets triggered on load and on new servers so it's a nice
// low-noise event to hook into...
case event.QueueJoinServer:
f.PublishServerUpdate(profile)
}