Add fullSync on successful import (#5500)

Analog to https://github.com/bitwarden/clients/pull/4380 we also need to add a full sync to the import.command, so that when a user calls `bw list items` those are populated.
This commit is contained in:
Daniel James Smith 2023-05-30 23:05:45 +02:00 committed by GitHub
parent 1247463e29
commit 4a552343f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import * as program from "commander";
import * as inquirer from "inquirer";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { ImportServiceAbstraction, ImportType } from "@bitwarden/importer";
import { Response } from "../models/response";
@ -11,7 +12,8 @@ import { CliUtils } from "../utils";
export class ImportCommand {
constructor(
private importService: ImportServiceAbstraction,
private organizationService: OrganizationService
private organizationService: OrganizationService,
private syncService: SyncService
) {}
async run(
@ -76,6 +78,7 @@ export class ImportCommand {
const response = await this.importService.import(importer, contents, organizationId);
if (response.success) {
this.syncService.fullSync(true);
return Response.success(new MessageResponse("Imported " + filepath, null));
}
} catch (err) {

View File

@ -442,7 +442,11 @@ export class VaultProgram extends Program {
})
.action(async (format, filepath, options) => {
await this.exitIfLocked();
const command = new ImportCommand(this.main.importService, this.main.organizationService);
const command = new ImportCommand(
this.main.importService,
this.main.organizationService,
this.main.syncService
);
const response = await command.run(format, filepath, options);
this.processResponse(response);
});