diff --git a/src/Events/Controllers/CollectController.cs b/src/Events/Controllers/CollectController.cs index 211efcf359..06ceaaaa80 100644 --- a/src/Events/Controllers/CollectController.cs +++ b/src/Events/Controllers/CollectController.cs @@ -40,6 +40,7 @@ namespace Bit.Events.Controllers return new BadRequestResult(); } var cipherEvents = new List>(); + var ciphersCache = new Dictionary(); foreach(var eventModel in model) { switch(eventModel.Type) @@ -61,12 +62,24 @@ namespace Bit.Events.Controllers { continue; } - var cipher = await _cipherRepository.GetByIdAsync(eventModel.CipherId.Value, - _currentContext.UserId.Value); + Cipher cipher = null; + if(ciphersCache.ContainsKey(eventModel.CipherId.Value)) + { + cipher = ciphersCache[eventModel.CipherId.Value]; + } + else + { + cipher = await _cipherRepository.GetByIdAsync(eventModel.CipherId.Value, + _currentContext.UserId.Value); + } if(cipher == null) { continue; } + if(!ciphersCache.ContainsKey(eventModel.CipherId.Value)) + { + ciphersCache.Add(eventModel.CipherId.Value, cipher); + } cipherEvents.Add(new Tuple(cipher, eventModel.Type, eventModel.Date)); break; default: