1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-05 23:53:21 +00:00
Files
directory-connector/src/commands/sync.command.ts
2022-03-03 11:09:04 +01:00

25 lines
903 B
TypeScript

import { I18nService } from "jslib-common/abstractions/i18n.service";
import { Response } from "jslib-node/cli/models/response";
import { MessageResponse } from "jslib-node/cli/models/response/messageResponse";
import { SyncService } from "../services/sync.service";
export class SyncCommand {
constructor(private syncService: SyncService, private i18nService: I18nService) {}
async run(): Promise<Response> {
try {
const result = await this.syncService.sync(false, false);
const groupCount = result[0] != null ? result[0].length : 0;
const userCount = result[1] != null ? result[1].length : 0;
const res = new MessageResponse(
this.i18nService.t("syncingComplete"),
this.i18nService.t("syncCounts", groupCount.toString(), userCount.toString())
);
return Response.success(res);
} catch (e) {
return Response.error(e);
}
}
}