fix: a few adjustments for matterbridge
- exposig Online info - adding ability to disable backup loop and auto message loop Issue #12710
This commit is contained in:
parent
6599be1721
commit
53ac61bb8b
|
@ -11,4 +11,10 @@ type FeatureFlags struct {
|
|||
|
||||
// MailserverCycle indicates whether we should enable or not the mailserver cycle
|
||||
MailserverCycle bool
|
||||
|
||||
// DisableCheckingForBackup disables backup loop
|
||||
DisableCheckingForBackup bool
|
||||
|
||||
// DisableAutoMessageLoop disables auto message loop
|
||||
DisableAutoMessageLoop bool
|
||||
}
|
||||
|
|
|
@ -796,10 +796,14 @@ func (m *Messenger) Start() (*MessengerResponse, error) {
|
|||
m.watchPendingCommunityRequestToJoin()
|
||||
m.broadcastLatestUserStatus()
|
||||
m.timeoutAutomaticStatusUpdates()
|
||||
m.startBackupLoop()
|
||||
err = m.startAutoMessageLoop()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if !m.config.featureFlags.DisableCheckingForBackup {
|
||||
m.startBackupLoop()
|
||||
}
|
||||
if !m.config.featureFlags.DisableAutoMessageLoop {
|
||||
err = m.startAutoMessageLoop()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
m.startSyncSettingsLoop()
|
||||
m.startSettingsChangesLoop()
|
||||
|
@ -930,7 +934,7 @@ func (m *Messenger) handleConnectionChange(online bool) {
|
|||
m.ensVerifier.SetOnline(online)
|
||||
}
|
||||
|
||||
func (m *Messenger) online() bool {
|
||||
func (m *Messenger) Online() bool {
|
||||
switch m.transport.WakuVersion() {
|
||||
case 2:
|
||||
return m.transport.PeerCount() > 0
|
||||
|
@ -1443,13 +1447,13 @@ func (m *Messenger) handleENSVerificationSubscription(c chan []*ens.Verification
|
|||
// watchConnectionChange checks the connection status and call handleConnectionChange when this changes
|
||||
func (m *Messenger) watchConnectionChange() {
|
||||
m.logger.Debug("watching connection changes")
|
||||
state := m.online()
|
||||
state := m.Online()
|
||||
m.handleConnectionChange(state)
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-time.After(200 * time.Millisecond):
|
||||
newState := m.online()
|
||||
newState := m.Online()
|
||||
if state != newState {
|
||||
state = newState
|
||||
m.logger.Debug("connection changed", zap.Bool("online", state))
|
||||
|
@ -1526,7 +1530,7 @@ func (m *Messenger) watchExpiredMessages() {
|
|||
for {
|
||||
select {
|
||||
case <-time.After(time.Second):
|
||||
if m.online() {
|
||||
if m.Online() {
|
||||
err := m.resendExpiredMessages()
|
||||
if err != nil {
|
||||
m.logger.Debug("Error when resending expired emoji reactions", zap.Error(err))
|
||||
|
@ -1609,7 +1613,7 @@ func (m *Messenger) PublishIdentityImage() error {
|
|||
}
|
||||
|
||||
// If not online, we schedule it
|
||||
if !m.online() {
|
||||
if !m.Online() {
|
||||
m.shouldPublishContactCode = true
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ func (m *Messenger) startBackupLoop() {
|
|||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
if !m.online() {
|
||||
if !m.Online() {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
@ -427,7 +427,7 @@ func (m *Messenger) handleCommunitiesSubscription(c chan *communities.Subscripti
|
|||
|
||||
case <-ticker.C:
|
||||
// If we are not online, we don't even try
|
||||
if !m.online() {
|
||||
if !m.Online() {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
@ -275,6 +275,20 @@ func WithPushNotifications() func(c *config) error {
|
|||
}
|
||||
}
|
||||
|
||||
func WithCheckingForBackupDisabled() func(c *config) error {
|
||||
return func(c *config) error {
|
||||
c.featureFlags.DisableCheckingForBackup = true
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func WithAutoMessageDisabled() func(c *config) error {
|
||||
return func(c *config) error {
|
||||
c.featureFlags.DisableAutoMessageLoop = true
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func WithEnvelopesMonitorConfig(emc *transport.EnvelopesMonitorConfig) Option {
|
||||
return func(c *config) error {
|
||||
c.envelopesMonitorConfig = emc
|
||||
|
|
|
@ -41,7 +41,7 @@ var maxTopicsPerRequest int = 10
|
|||
var ErrNoFiltersForChat = errors.New("no filter registered for given chat")
|
||||
|
||||
func (m *Messenger) shouldSync() (bool, error) {
|
||||
if m.mailserverCycle.activeMailserver == nil || !m.online() {
|
||||
if m.mailserverCycle.activeMailserver == nil || !m.Online() {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue