diff --git a/src/App/Abstractions/Repositories/IFolderRepository.cs b/src/App/Abstractions/Repositories/IFolderRepository.cs index 57045d646..92f3cc600 100644 --- a/src/App/Abstractions/Repositories/IFolderRepository.cs +++ b/src/App/Abstractions/Repositories/IFolderRepository.cs @@ -8,5 +8,6 @@ namespace Bit.App.Abstractions public interface IFolderRepository : IRepository { Task> GetAllByUserIdAsync(string userId); + Task DeleteWithSiteUpdateAsync(string id, DateTime revisionDate); } } diff --git a/src/App/Abstractions/Services/ISyncService.cs b/src/App/Abstractions/Services/ISyncService.cs index 8515bf906..305afef6a 100644 --- a/src/App/Abstractions/Services/ISyncService.cs +++ b/src/App/Abstractions/Services/ISyncService.cs @@ -7,7 +7,7 @@ namespace Bit.App.Abstractions { bool SyncInProgress { get; } Task SyncAsync(string id); - Task SyncDeleteFolderAsync(string id); + Task SyncDeleteFolderAsync(string id, DateTime revisionDate); Task SyncDeleteSiteAsync(string id); Task FullSyncAsync(); Task IncrementalSyncAsync(TimeSpan syncThreshold); diff --git a/src/App/Repositories/FolderRepository.cs b/src/App/Repositories/FolderRepository.cs index 0b636caf7..7be067321 100644 --- a/src/App/Repositories/FolderRepository.cs +++ b/src/App/Repositories/FolderRepository.cs @@ -18,5 +18,23 @@ namespace Bit.App.Repositories var folders = Connection.Table().Where(f => f.UserId == userId).Cast(); return Task.FromResult(folders); } + + public override Task DeleteAsync(string id) + { + var now = DateTime.UtcNow; + DeleteWithSiteUpdateAsync(id, now); + return Task.FromResult(0); + } + + public Task DeleteWithSiteUpdateAsync(string id, DateTime revisionDate) + { + Connection.RunInTransaction(() => + { + Connection.Execute("UPDATE Site SET FolderId = ?, RevisionDateTime = ? WHERE FolderId = ?", null, revisionDate, id); + Connection.Delete(id); + }); + + return Task.FromResult(0); + } } } diff --git a/src/App/Services/PushNotificationListener.cs b/src/App/Services/PushNotificationListener.cs index 5d681058d..4e344dcf4 100644 --- a/src/App/Services/PushNotificationListener.cs +++ b/src/App/Services/PushNotificationListener.cs @@ -59,7 +59,7 @@ namespace Bit.App.Services break; case Enums.PushType.SyncFolderDelete: var folderDeleteMessage = values.ToObject(); - _syncService.SyncDeleteFolderAsync(folderDeleteMessage.Id); + _syncService.SyncDeleteFolderAsync(folderDeleteMessage.Id, folderDeleteMessage.RevisionDate); break; case Enums.PushType.SyncSiteDelete: var siteDeleteMessage = values.ToObject(); diff --git a/src/App/Services/SyncService.cs b/src/App/Services/SyncService.cs index 30b7ff922..9da96450e 100644 --- a/src/App/Services/SyncService.cs +++ b/src/App/Services/SyncService.cs @@ -98,7 +98,7 @@ namespace Bit.App.Services return true; } - public async Task SyncDeleteFolderAsync(string id) + public async Task SyncDeleteFolderAsync(string id, DateTime revisionDate) { if(!_authService.IsAuthenticated) { @@ -107,7 +107,7 @@ namespace Bit.App.Services SyncStarted(); - await _folderRepository.DeleteAsync(id); + await _folderRepository.DeleteWithSiteUpdateAsync(id, revisionDate); SyncCompleted(true); return true; }