src/permissions/PermissionManager.ts
import {PermissionService} from '../wac-proxy/wac-stack/permissions/PermissionService';
import {RecordingProfile} from '../wac-proxy/wac-stack/permissions/ServerPermissions';
/**
* This class allows manager the permissions. To obtain an instance of the
* class {@linkSession#getPermissionManager} method must be used.
*/
export class PermissionManager {
/** @private */
private permissionService: PermissionService;
/** @ignore */
constructor(permissionService: PermissionService) {
this.permissionService = permissionService;
}
/** @ignore */
async init(): Promise<void> {
await this.permissionService.retrieve();
}
/**
* Returns if the user has permissions to set the conference record option
* @returns {boolean}
* @throws {NotInitializedError} thrown when the {@link PermissionManager} was not initialized
*/
canSetRecordOption(): boolean {
return this.permissionService.get().recording.recordingProfile === RecordingProfile.OPTIONAL;
}
/**
* Returns whether the conferences created by the user will be recorded
* @returns {boolean}
* @throws {NotInitializedError} thrown when the {@link PermissionManager} was not initialized
*/
canAlwaysRecord(): boolean {
return this.permissionService.get().recording.recordingProfile === RecordingProfile.ALWAYS;
}
/**
* Returns if the VoiceMail is enabled or not to the user
* @returns {boolean}
* @throws {NotInitializedError} thrown when the {@link PermissionManager} was not initialized
*/
canUseVoiceMail(): boolean {
return this.permissionService.get().voicemail.enabled;
}
}