mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-15 07:43:27 +00:00
30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
import * as program from 'commander';
|
|
|
|
import { ConfigurationService } from '../services/configuration.service';
|
|
|
|
import { Response } from 'jslib/cli/models/response';
|
|
import { StringResponse } from 'jslib/cli/models/response/stringResponse';
|
|
|
|
export class LastSyncCommand {
|
|
constructor(private configurationService: ConfigurationService) { }
|
|
|
|
async run(object: string, cmd: program.Command): Promise<Response> {
|
|
try {
|
|
switch (object.toLowerCase()) {
|
|
case 'groups':
|
|
const groupsDate = await this.configurationService.getLastGroupSyncDate();
|
|
const groupsRes = new StringResponse(groupsDate == null ? null : groupsDate.toISOString());
|
|
return Response.success(groupsRes);
|
|
case 'users':
|
|
const usersDate = await this.configurationService.getLastUserSyncDate();
|
|
const usersRes = new StringResponse(usersDate == null ? null : usersDate.toISOString());
|
|
return Response.success(usersRes);
|
|
default:
|
|
return Response.badRequest('Unknown object.');
|
|
}
|
|
} catch (e) {
|
|
return Response.error(e);
|
|
}
|
|
}
|
|
}
|