Exemplo n.º 1
0
        public async Task DeleteManyAsync(IEnumerable <Guid> cipherIds, Guid deletingUserId)
        {
            await _cipherRepository.DeleteAsync(cipherIds, deletingUserId);

            // push
            await _pushService.PushSyncCiphersAsync(deletingUserId);
        }
Exemplo n.º 2
0
        public async Task DeleteManyAsync(IEnumerable <Guid> cipherIds, Guid deletingUserId, Guid?organizationId = null, bool orgAdmin = false)
        {
            var cipherIdsSet    = new HashSet <Guid>(cipherIds);
            var deletingCiphers = new List <Cipher>();

            if (orgAdmin && organizationId.HasValue)
            {
                var ciphers = await _cipherRepository.GetManyByOrganizationIdAsync(organizationId.Value);

                deletingCiphers = ciphers.Where(c => cipherIdsSet.Contains(c.Id)).ToList();
                await _cipherRepository.DeleteByIdsOrganizationIdAsync(deletingCiphers.Select(c => c.Id), organizationId.Value);
            }
            else
            {
                var ciphers = await _cipherRepository.GetManyByUserIdAsync(deletingUserId);

                deletingCiphers = ciphers.Where(c => cipherIdsSet.Contains(c.Id) && c.Edit).Select(x => (Cipher)x).ToList();
                await _cipherRepository.DeleteAsync(deletingCiphers.Select(c => c.Id), deletingUserId);
            }

            var events = deletingCiphers.Select(c =>
                                                new Tuple <Cipher, EventType, DateTime?>(c, EventType.Cipher_Deleted, null));

            foreach (var eventsBatch in events.Batch(100))
            {
                await _eventService.LogCipherEventsAsync(eventsBatch);
            }

            // push
            await _pushService.PushSyncCiphersAsync(deletingUserId);
        }
Exemplo n.º 3
0
        public async Task DeleteManyAsync(IEnumerable <Guid> cipherIds, Guid deletingUserId)
        {
            var cipherIdsSet = new HashSet <Guid>(cipherIds);
            var ciphers      = await _cipherRepository.GetManyByUserIdAsync(deletingUserId);

            var deletingCiphers = ciphers.Where(c => cipherIdsSet.Contains(c.Id) && c.Edit);

            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);
            }

            // push
            await _pushService.PushSyncCiphersAsync(deletingUserId);
        }
Exemplo n.º 4
0
        public async Task DeleteManyAsync(IEnumerable <Guid> cipherIds, Guid deletingUserId)
        {
            var cipherIdsSet = new HashSet <Guid>(cipherIds);
            var ciphers      = await _cipherRepository.GetManyByUserIdAsync(deletingUserId);

            var deletingCiphers = ciphers.Where(c => cipherIdsSet.Contains(c.Id) && c.Edit);

            await _cipherRepository.DeleteAsync(cipherIds, deletingUserId);

            var events = deletingCiphers.Select(c =>
                                                new Tuple <Cipher, EventType, DateTime?>(c, EventType.Cipher_Deleted, null));

            foreach (var eventsBatch in events.Batch(100))
            {
                await _eventService.LogCipherEventsAsync(eventsBatch);
            }

            // push
            await _pushService.PushSyncCiphersAsync(deletingUserId);
        }