@ -54,12 +54,11 @@ public class ImportCiphersCommand : IImportCiphersCommand
public async Task ImportIntoIndividualVaultAsync (
public async Task ImportIntoIndividualVaultAsync (
List < Folder > folders ,
List < Folder > folders ,
List < CipherDetails > ciphers ,
List < CipherDetails > ciphers ,
IEnumerable < KeyValuePair < int , int > > folderRelationships )
IEnumerable < KeyValuePair < int , int > > folderRelationships ,
Guid importingUserId )
{
{
var userId = folders . FirstOrDefault ( ) ? . UserId ? ? ciphers . FirstOrDefault ( ) ? . UserId ;
// Make sure the user can save new ciphers to their personal vault
// Make sure the user can save new ciphers to their personal vault
var anyPersonalOwnershipPolicies = await _ policyService . AnyPoliciesApplicableToUserAsync ( userId . Value , PolicyType . PersonalOwnership ) ;
var anyPersonalOwnershipPolicies = await _ policyService . AnyPoliciesApplicableToUserAsync ( importingUserId , PolicyType . PersonalOwnership ) ;
if ( anyPersonalOwnershipPolicies )
if ( anyPersonalOwnershipPolicies )
{
{
throw new BadRequestException ( "You cannot import items into your personal vault because you are " +
throw new BadRequestException ( "You cannot import items into your personal vault because you are " +
@ -76,7 +75,7 @@ public class ImportCiphersCommand : IImportCiphersCommand
}
}
}
}
var userfoldersIds = ( await _f olderRepository . GetManyByUserIdAsync ( userId ? ? Guid . Empty ) ) . Select ( f = > f . Id ) . ToList ( ) ;
var userfoldersIds = ( await _f olderRepository . GetManyByUserIdAsync ( importingUserId ) ) . Select ( f = > f . Id ) . ToList ( ) ;
//Assign id to the ones that don't exist in DB
//Assign id to the ones that don't exist in DB
//Need to keep the list order to create the relationships
//Need to keep the list order to create the relationships
@ -109,10 +108,7 @@ public class ImportCiphersCommand : IImportCiphersCommand
await _ cipherRepository . CreateAsync ( ciphers , newFolders ) ;
await _ cipherRepository . CreateAsync ( ciphers , newFolders ) ;
// push
// push
if ( userId . HasValue )
await _ pushService . PushSyncVaultAsync ( importingUserId ) ;
{
await _ pushService . PushSyncVaultAsync ( userId . Value ) ;
}
}
}
public async Task ImportIntoOrganizationalVaultAsync (
public async Task ImportIntoOrganizationalVaultAsync (