public async Task DeleteAttachmentAsync(Cipher cipher, string attachmentId, Guid deletingUserId, bool orgAdmin = false) { if (!orgAdmin && !(await UserCanEditAsync(cipher, deletingUserId))) { throw new BadRequestException("You do not have permissions to delete this."); } if (!cipher.ContainsAttachment(attachmentId)) { throw new NotFoundException(); } await _cipherRepository.DeleteAttachmentAsync(cipher.Id, attachmentId); cipher.DeleteAttachment(attachmentId); await _attachmentStorageService.DeleteAttachmentAsync(cipher.Id, attachmentId); // push await _pushService.PushSyncCipherUpdateAsync(cipher); }
public async Task DeleteAttachmentAsync(Cipher cipher, string attachmentId, Guid deletingUserId, bool orgAdmin = false) { if (!orgAdmin && !(await UserCanEditAsync(cipher, deletingUserId))) { throw new BadRequestException("You do not have permissions to delete this."); } if (!cipher.ContainsAttachment(attachmentId)) { throw new NotFoundException(); } var data = cipher.GetAttachments()[attachmentId]; await _cipherRepository.DeleteAttachmentAsync(cipher.Id, attachmentId); cipher.DeleteAttachment(attachmentId); await _attachmentStorageService.DeleteAttachmentAsync(cipher.Id, data); await _eventService.LogCipherEventAsync(cipher, Enums.EventType.Cipher_AttachmentDeleted); // push await _pushService.PushSyncCipherUpdateAsync(cipher, null); }