mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-12 14:23:21 +00:00
data-file and last-sync commands
This commit is contained in:
29
src/commands/lastSync.command.ts
Normal file
29
src/commands/lastSync.command.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user