From 675b22cc9f2167400b79947ba803c45ed6c94539 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 25 Jul 2019 15:39:25 -0400 Subject: [PATCH] single event for delete and share bulk operations --- .../Services/Implementations/CipherService.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Core/Services/Implementations/CipherService.cs b/src/Core/Services/Implementations/CipherService.cs index cb9ead040..c77967930 100644 --- a/src/Core/Services/Implementations/CipherService.cs +++ b/src/Core/Services/Implementations/CipherService.cs @@ -9,6 +9,7 @@ using Bit.Core.Exceptions; using Bit.Core.Models.Data; using Newtonsoft.Json; using System.IO; +using Bit.Core.Enums; namespace Bit.Core.Services { @@ -294,11 +295,9 @@ namespace Bit.Core.Services await _cipherRepository.DeleteAsync(cipherIds, deletingUserId); - // TODO: move this to a single event? - foreach(var cipher in deletingCiphers) - { - await _eventService.LogCipherEventAsync(cipher, Enums.EventType.Cipher_Deleted); - } + var events = deletingCiphers.Select(c => + new Tuple(c, EventType.Cipher_Deleted, null)); + await _eventService.LogCipherEventsAsync(events); // push await _pushService.PushSyncCiphersAsync(deletingUserId); @@ -508,11 +507,9 @@ namespace Bit.Core.Services await _collectionCipherRepository.UpdateCollectionsForCiphersAsync(cipherIds, sharingUserId, organizationId, collectionIds); - // TODO: move this to a single event? - foreach(var cipher in ciphers) - { - await _eventService.LogCipherEventAsync(cipher, Enums.EventType.Cipher_Shared); - } + var events = ciphers.Select(c => + new Tuple(c, EventType.Cipher_Shared, null)); + await _eventService.LogCipherEventsAsync(events); // push await _pushService.PushSyncCiphersAsync(sharingUserId);