Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/Api/Vault/Controllers/CiphersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ await _cipherService.CreateAttachmentShareAsync(cipher, stream, fileName, key,
}

[HttpDelete("{id}/attachment/{attachmentId}")]
public async Task<DeleteAttachmentResponseData> DeleteAttachment(Guid id, string attachmentId)
public async Task<DeleteAttachmentResponseModel> DeleteAttachment(Guid id, string attachmentId)
{
var userId = _userService.GetProperUserId(User).Value;
var cipher = await GetByIdAsync(id, userId);
Expand All @@ -1533,18 +1533,19 @@ public async Task<DeleteAttachmentResponseData> DeleteAttachment(Guid id, string
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<DeleteAttachmentResponseData> PostDeleteAttachment(Guid id, string attachmentId)
public async Task<DeleteAttachmentResponseModel> PostDeleteAttachment(Guid id, string attachmentId)
{
return await DeleteAttachment(id, attachmentId);
}

[HttpDelete("{id}/attachment/{attachmentId}/admin")]
public async Task<DeleteAttachmentResponseData> DeleteAttachmentAdmin(Guid id, string attachmentId)
public async Task<DeleteAttachmentResponseModel> DeleteAttachmentAdmin(Guid id, string attachmentId)
{
var userId = _userService.GetProperUserId(User).Value;
var cipher = await _cipherRepository.GetByIdAsync(id);
Expand All @@ -1554,12 +1555,13 @@ public async Task<DeleteAttachmentResponseData> DeleteAttachmentAdmin(Guid id, s
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<DeleteAttachmentResponseData> PostDeleteAttachmentAdmin(Guid id, string attachmentId)
public async Task<DeleteAttachmentResponseModel> PostDeleteAttachmentAdmin(Guid id, string attachmentId)
{
return await DeleteAttachmentAdmin(id, attachmentId);
}
Expand Down
11 changes: 11 additions & 0 deletions src/Api/Vault/Models/Response/DeleteAttachmentResponseModel.cs
Original file line number Diff line number Diff line change
@@ -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);
}
Loading