Skip to content

Commit a0e93c8

Browse files
committed
fix(backup)_: do not show the backup notifi backup during normal fetch
Fixes status-im/status-desktop#17555 We were adding the Notification of the back ups by accident when creating a normal account (not restored), because I added the code to create the notification in the `RequestAllHistoricMessages` function as well, even though the Messenger already does it. So for normal restores, it probably tried to add it twice, though they have the same ID, so it wasn't noticed
1 parent 7f81efb commit a0e93c8

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

protocol/messenger_backup_handler.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ func (m *Messenger) handleBackup(state *ReceivedMessageState, message *protobuf.
127127
}
128128

129129
func (m *Messenger) updateBackupFetchProgress(message *protobuf.Backup, response *wakusync.WakuBackedUpDataResponse, state *ReceivedMessageState) error {
130+
if m.backedUpFetchingStatus == nil {
131+
return nil
132+
}
133+
130134
m.backedUpFetchingStatus.fetchingCompletedMutex.Lock()
131135
defer m.backedUpFetchingStatus.fetchingCompletedMutex.Unlock()
132136

protocol/messenger_backup_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,37 @@ func (s *MessengerBackupSuite) TestFetchingDuringBackup() {
417417
s.Require().Equal(ActivityCenterNotificationTypeBackupSyncingSuccess, state.Response.ActivityCenterNotifications()[0].Type)
418418
}
419419

420+
func (s *MessengerBackupSuite) TestBackupWithoutStatusFetching() {
421+
bob1 := s.m
422+
// Remove the status fetching
423+
bob1.backedUpFetchingStatus = nil
424+
bob1.config.messengerSignalsHandler = &MessengerSignalsHandlerMock{
425+
wakuBackedUpDataResponseChan: make(chan *wakusync.WakuBackedUpDataResponse, 1000),
426+
}
427+
428+
state := ReceivedMessageState{
429+
Response: &MessengerResponse{},
430+
}
431+
432+
backup := &protobuf.Backup{
433+
Clock: 1,
434+
ContactsDetails: &protobuf.FetchingBackedUpDataDetails{
435+
DataNumber: uint32(0),
436+
TotalNumber: uint32(1),
437+
},
438+
}
439+
440+
err := bob1.HandleBackup(
441+
&state,
442+
backup,
443+
&v1protocol.StatusMessage{},
444+
)
445+
s.Require().NoError(err)
446+
// The backup was handled but nothing was sent to the AC
447+
s.Require().Len(state.Response.ActivityCenterNotifications(), 0)
448+
s.Require().True(state.Response.BackupHandled)
449+
}
450+
420451
func (s *MessengerBackupSuite) TestBackupSettings() {
421452
s.T().Skip("flaky test")
422453
const (

protocol/messenger_mailserver.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,6 @@ func (m *Messenger) RequestAllHistoricMessages(forceFetchingBackup, withRetries
320320

321321
allResponses := &MessengerResponse{}
322322
if forceFetchingBackup || !backupFetched {
323-
err = m.startBackupFetchingTracking(allResponses)
324-
if err != nil {
325-
return nil, err
326-
}
327-
328323
m.logger.Info("fetching backup")
329324
err := m.syncBackup()
330325
if err != nil {

0 commit comments

Comments
 (0)