diff --git a/src/Api/Vault/Controllers/CiphersController.cs b/src/Api/Vault/Controllers/CiphersController.cs index c9ca7525fa..9ead8bc4bd 100644 --- a/src/Api/Vault/Controllers/CiphersController.cs +++ b/src/Api/Vault/Controllers/CiphersController.cs @@ -1524,7 +1524,7 @@ public class CiphersController : Controller } [HttpDelete("{id}/attachment/{attachmentId}")] - public async Task DeleteAttachment(Guid id, string attachmentId) + public async Task DeleteAttachment(Guid id, string attachmentId) { var userId = _userService.GetProperUserId(User).Value; var cipher = await GetByIdAsync(id, userId); @@ -1533,18 +1533,19 @@ public class CiphersController : Controller throw new NotFoundException(); } - return await _cipherService.DeleteAttachmentAsync(cipher, attachmentId, userId, false); + var result = await _cipherService.DeleteAttachmentAsync(cipher, attachmentId, userId, false); + return new DeleteAttachmentResponseModel(result, _globalSettings); } [HttpPost("{id}/attachment/{attachmentId}/delete")] [Obsolete("This endpoint is deprecated. Use DELETE method instead.")] - public async Task PostDeleteAttachment(Guid id, string attachmentId) + public async Task PostDeleteAttachment(Guid id, string attachmentId) { return await DeleteAttachment(id, attachmentId); } [HttpDelete("{id}/attachment/{attachmentId}/admin")] - public async Task DeleteAttachmentAdmin(Guid id, string attachmentId) + public async Task DeleteAttachmentAdmin(Guid id, string attachmentId) { var userId = _userService.GetProperUserId(User).Value; var cipher = await _cipherRepository.GetByIdAsync(id); @@ -1554,12 +1555,13 @@ public class CiphersController : Controller throw new NotFoundException(); } - return await _cipherService.DeleteAttachmentAsync(cipher, attachmentId, userId, true); + var result = await _cipherService.DeleteAttachmentAsync(cipher, attachmentId, userId, true); + return new DeleteAttachmentResponseModel(result, _globalSettings); } [HttpPost("{id}/attachment/{attachmentId}/delete-admin")] [Obsolete("This endpoint is deprecated. Use DELETE method instead.")] - public async Task PostDeleteAttachmentAdmin(Guid id, string attachmentId) + public async Task PostDeleteAttachmentAdmin(Guid id, string attachmentId) { return await DeleteAttachmentAdmin(id, attachmentId); } diff --git a/src/Api/Vault/Models/Response/DeleteAttachmentResponseModel.cs b/src/Api/Vault/Models/Response/DeleteAttachmentResponseModel.cs new file mode 100644 index 0000000000..a64eb0c104 --- /dev/null +++ b/src/Api/Vault/Models/Response/DeleteAttachmentResponseModel.cs @@ -0,0 +1,11 @@ +using Bit.Core.Models.Api; +using Bit.Core.Settings; +using Bit.Core.Vault.Models.Data; + +namespace Bit.Api.Vault.Models.Response; + +public class DeleteAttachmentResponseModel(DeleteAttachmentResponseData data, IGlobalSettings globalSettings) + : ResponseModel("deleteAttachment") +{ + public CipherMiniResponseModel Cipher { get; set; } = new(data.Cipher, globalSettings, false); +}