@ -911,7 +911,7 @@ public class CiphersController : Controller
@@ -911,7 +911,7 @@ public class CiphersController : Controller
[HttpPut("{id}/archive")]
[RequireFeature(FeatureFlagKeys.ArchiveVaultItems)]
public async Task < CipherMini ResponseModel > PutArchive ( Guid id )
public async Task < CipherResponseModel > PutArchive ( Guid id )
{
var userId = _ userService . GetProperUserId ( User ) . Value ;
@ -922,12 +922,16 @@ public class CiphersController : Controller
@@ -922,12 +922,16 @@ public class CiphersController : Controller
throw new BadRequestException ( "Cipher was not archived. Ensure the provided ID is correct and you have permission to archive it." ) ;
}
return new CipherMiniResponseModel ( archivedCipherOrganizationDetails . First ( ) , _ globalSettings , archivedCipherOrganizationDetails . First ( ) . OrganizationUseTotp ) ;
return new CipherResponseModel ( archivedCipherOrganizationDetails . First ( ) ,
await _ userService . GetUserByIdAsync ( userId ) ,
await _ applicationCacheService . GetOrganizationAbilitiesAsync ( ) ,
_ globalSettings
) ;
}
[HttpPut("archive")]
[RequireFeature(FeatureFlagKeys.ArchiveVaultItems)]
public async Task < ListResponseModel < CipherMini ResponseModel > > PutArchiveMany ( [ FromBody ] CipherBulkArchiveRequestModel model )
public async Task < ListResponseModel < CipherResponseModel > > PutArchiveMany ( [ FromBody ] CipherBulkArchiveRequestModel model )
{
if ( ! _ globalSettings . SelfHosted & & model . Ids . Count ( ) > 5 0 0 )
{
@ -935,6 +939,7 @@ public class CiphersController : Controller
@@ -935,6 +939,7 @@ public class CiphersController : Controller
}
var userId = _ userService . GetProperUserId ( User ) . Value ;
var user = await _ userService . GetUserByIdAsync ( userId ) ;
var cipherIdsToArchive = new HashSet < Guid > ( model . Ids ) ;
@ -945,9 +950,14 @@ public class CiphersController : Controller
@@ -945,9 +950,14 @@ public class CiphersController : Controller
throw new BadRequestException ( "No ciphers were archived. Ensure the provided IDs are correct and you have permission to archive them." ) ;
}
var responses = archivedCiphers . Select ( c = > new CipherMiniResponseModel ( c , _ globalSettings , c . OrganizationUseTotp ) ) ;
var organizationAbilities = await _ applicationCacheService . GetOrganizationAbilitiesAsync ( ) ;
var responses = archivedCiphers . Select ( c = > new CipherResponseModel ( c ,
user ,
organizationAbilities ,
_ globalSettings
) ) ;
return new ListResponseModel < CipherMiniResponseModel > ( responses ) ;
return new ListResponseModel < CipherResponseModel > ( responses ) ;
}
[HttpDelete("{id}")]
@ -1109,7 +1119,7 @@ public class CiphersController : Controller
@@ -1109,7 +1119,7 @@ public class CiphersController : Controller
[HttpPut("{id}/unarchive")]
[RequireFeature(FeatureFlagKeys.ArchiveVaultItems)]
public async Task < CipherMini ResponseModel > PutUnarchive ( Guid id )
public async Task < CipherResponseModel > PutUnarchive ( Guid id )
{
var userId = _ userService . GetProperUserId ( User ) . Value ;
@ -1120,12 +1130,16 @@ public class CiphersController : Controller
@@ -1120,12 +1130,16 @@ public class CiphersController : Controller
throw new BadRequestException ( "Cipher was not unarchived. Ensure the provided ID is correct and you have permission to archive it." ) ;
}
return new CipherMiniResponseModel ( unarchivedCipherDetails . First ( ) , _ globalSettings , unarchivedCipherDetails . First ( ) . OrganizationUseTotp ) ;
return new CipherResponseModel ( unarchivedCipherDetails . First ( ) ,
await _ userService . GetUserByIdAsync ( userId ) ,
await _ applicationCacheService . GetOrganizationAbilitiesAsync ( ) ,
_ globalSettings
) ;
}
[HttpPut("unarchive")]
[RequireFeature(FeatureFlagKeys.ArchiveVaultItems)]
public async Task < ListResponseModel < CipherMini ResponseModel > > PutUnarchiveMany ( [ FromBody ] CipherBulkUnarchiveRequestModel model )
public async Task < ListResponseModel < CipherResponseModel > > PutUnarchiveMany ( [ FromBody ] CipherBulkUnarchiveRequestModel model )
{
if ( ! _ globalSettings . SelfHosted & & model . Ids . Count ( ) > 5 0 0 )
{
@ -1133,6 +1147,8 @@ public class CiphersController : Controller
@@ -1133,6 +1147,8 @@ public class CiphersController : Controller
}
var userId = _ userService . GetProperUserId ( User ) . Value ;
var user = await _ userService . GetUserByIdAsync ( userId ) ;
var organizationAbilities = await _ applicationCacheService . GetOrganizationAbilitiesAsync ( ) ;
var cipherIdsToUnarchive = new HashSet < Guid > ( model . Ids ) ;
@ -1143,9 +1159,9 @@ public class CiphersController : Controller
@@ -1143,9 +1159,9 @@ public class CiphersController : Controller
throw new BadRequestException ( "Ciphers were not unarchived. Ensure the provided ID is correct and you have permission to archive it." ) ;
}
var responses = unarchivedCipherOrganizationDetails . Select ( c = > new CipherMini ResponseModel ( c , _ globalSettings , c . OrganizationUseTotp ) ) ;
var responses = unarchivedCipherOrganizationDetails . Select ( c = > new CipherResponseModel ( c , user , organizationAbilities , _ globalSettings ) ) ;
return new ListResponseModel < CipherMini ResponseModel > ( responses ) ;
return new ListResponseModel < CipherResponseModel > ( responses ) ;
}
[HttpPut("{id}/restore")]