mirror of
https://github.com/bitwarden/server
synced 2026-02-18 10:23:27 +00:00
Updated delete attachment actions to return a DeleteAttachmentResponseModel (#7013)
This commit is contained in:
@@ -1524,7 +1524,7 @@ public class CiphersController : Controller
|
||||
}
|
||||
|
||||
[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);
|
||||
@@ -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<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);
|
||||
@@ -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<DeleteAttachmentResponseData> PostDeleteAttachmentAdmin(Guid id, string attachmentId)
|
||||
public async Task<DeleteAttachmentResponseModel> PostDeleteAttachmentAdmin(Guid id, string attachmentId)
|
||||
{
|
||||
return await DeleteAttachmentAdmin(id, attachmentId);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user