API Docs for: 2.6
Show:

controller_user Class

Module: user

Provides the user functionalities.

Methods

addEndpointsToUser

(
  • user
  • endpoType
  • obj
)
private

Adds all endpoints to the user.

Parameters:

  • user Object

    The user object

  • endpoType String

    The type of the endpoint

  • obj Object

    Contains the list of the endpoints with their relative object

config

(
  • data
)

Set configuration to use and initialize the users. It can be possible only configuration by file.

The method can throw an Exception.

Parameters:

  • data Object
    • file String

      JSON file with the user/endpoint associations and the authorization data.

configByFile

(
  • path
)
private

Initialize the users by file. The file must use the JSON syntax and must report user/endpoint associations and authorization data.

It emits "users_ready" event when the user creation is completed.

Parameters:

  • path String

    The path of the JSON file with the user/endpoints associations and the authorization data

emit

(
  • ev
  • data
)

Emit an event. It's the same of nodejs events.EventEmitter.emit method.

Parameters:

  • ev String

    The name of the event

  • data Object

    The object to be emitted

getAllEndpointsCellphone

(
  • username
)
Object

Returns all the cellphone endpoints of the user.

Parameters:

  • username String

    The username

Returns:

Object:

Returns all the cellphone endpoints of the user.

getAllEndpointsEmail

(
  • username
)
Object

Returns all the email endpoints of the user.

Parameters:

  • username String

    The username

Returns:

Object:

Returns all the email endpoints of the user.

getAllEndpointsExtension

(
  • username
)
Object

Returns all the extension endpoints of the user.

Parameters:

  • username String

    The username

Returns:

Object:

Returns all the extension endpoints of the user.

getAllEndpointsNethcti

(
  • username
)
Object

Returns all the nethcti endpoints of the user.

Parameters:

  • username String

    The username

Returns:

Object:

Returns all the nethcti endpoints of the user.

getAllUsersEndpointsExtension

() Object

Returns all the extension endpoints of all users.

Returns:

Object:

Returns all the extension endpoints of all users.

getAllUsersEndpointsJSON

() Object

Returns the endpoints of all users.

Returns:

Object:

The endpoints of all users in JSON format.

getAuthorization

(
  • userid
)
Object

Gets an authorization of the specified user.

Parameters:

  • userid String

    The user identifier

Returns:

Object:

The authorization of the user or undefined value if the user doesn't exist.

getConfigurations

(
  • userid
)
Object

Gets the user configurations.

Parameters:

  • userid String

    The user identifier

Returns:

Object:

The configurations of the user or an empty object if some errors occurs.

getEndpointsJSON

(
  • userid
)
Object

Returns the endpoints of the user.

Parameters:

  • userid String

    The user identifier

Returns:

Object:

The endpoints of the user in JSON format.

getUsernames

() Array

Returns the list of all the usernames.

Returns:

Array:

The list of all the usernames.

getUsernamesWithData

() Object

Returns the list of all the usernames with their names and surnames.

Returns:

Object:

The list of all the usernames with their names and surnames.

getUsersUsingEndpointExtension

(
  • exten
)
Array

Returns all users associated with the specified extension endpoint.

Parameters:

  • exten String

    The extension endpoint identifier

Returns:

Array:

Returns all the users associated with the specified extension endpoint.

getUsersUsingEndpointVoicemail

(
  • voicemail
)
Array

Returns all users associated with the specified voicemail endpoint.

Parameters:

  • voicemail String

    The voicemail endpoint identifier

Returns:

Array:

Returns all the users associated with the specified voicemail endpoint.

getVoicemailList

(
  • username
)
Array

Returns the voicemail list of the user.

Parameters:

  • username String

    The name of the user to check

Returns:

Array:

The voicemail list of the user.

hasCellphoneEndpoint

(
  • username
  • exten
)

Check if the user has the cellphone endpoint.

Parameters:

  • username String

    The name of the user to check

  • exten String

    The cellphone identifier

Returns:

True if the user has the cellphone endpoint, false otherwise.

hasExtensionEndpoint

(
  • username
  • exten
)

Check if the user has an extension endpoint.

Parameters:

  • username String

    The name of the user to check

  • exten String

    The extension identifier

Returns:

True if the user has the extension endpoint, false otherwise.

hasVoicemailEndpoint

(
  • username
  • voicemail
)
Boolean

Check if the user has the specified voicemail endpoint.

Parameters:

  • username String

    The name of the user to check

  • voicemail String

    The voicemail endpoint identifier

Returns:

Boolean:

True if the user has the voicemail endpoint, false otherwise.

initializeEndpointsUsersByJSON

(
  • json
)
private

Adds the endpoint objects to the user by json configuration.

Parameters:

  • json Object

    The JSON configuration

isDesktopLoggedIn

(
  • username
  • True
)

Checks if the user is logged into the cti by a desktop device.

Parameters:

  • username String

    The username

  • True Boolean

    if the user is logged into the cti by a desktop device.

isLoggedInByDevice

(
  • username
  • deviceType
  • True
)

Checks if the user is logged into the cti by the specified device.

Parameters:

  • username String

    The username

  • deviceType String

    The device type used for nethcti

  • True Boolean

    if the user is logged into the cti by the specified device.

isMobileLoggedIn

(
  • username
  • True
)

Checks if the user is logged into the cti by a mobile device.

Parameters:

  • username String

    The username

  • True Boolean

    if the user is logged into the cti by a mobile device.

isUserPresent

(
  • username
)
Boolean

Checks if the user exists. To be present, it must be configured.

Parameters:

  • username String

    The name of the user to be checked.

Returns:

Boolean:

True if the user exists.

on

(
  • type
  • cb
)
Object

Subscribe a callback function to a custom event fired by this object. It's the same of nodejs events.EventEmitter.on method.

Parameters:

  • type String

    The name of the event

  • cb Function

    The callback to execute in response to the event

Returns:

Object:

A subscription handle capable of detaching that subscription.

setAuthorization

(
  • userid
  • typeAutho
  • value
)

Sets an authorization to the specified user.

Parameters:

  • userid String

    The user identifier

  • typeAutho String

    The type of the authorization

  • value String | Array

    The value of the autorization. It can be "true" or "false" or an array of value as in the case of customer card or streaming authorizations.

setConfigurations

(
  • userid
  • config
)

Sets the configurations to the specified user.

It can throw an Exception.

Parameters:

  • userid String

    The user identifier

  • config Object

    The user configurations

setLogger

(
  • log
)
static

Set the logger to be used.

Parameters:

  • log Object

    The logger object. It must have at least three methods: info, warn and error as console object.

setNethctiPresence

(
  • username
  • deviceType
  • status
  • True
)

Sets the nethcti presence of the user.

Parameters:

  • username String

    The username

  • deviceType String

    The device type used for nethcti

  • status String

    The status of the nethcti presence

  • True Boolean

    if the NethCTI presence has been set successfully

Properties

emitter

Object private

The event emitter.

EVT_ENDPOINT_PRESENCE_CHANGED

String

The name of the user endpoint presence changed event.

Default: "endpointPresenceChanged"

EVT_USERS_READY

String

The name of the users ready event.

Default: "usersReady"

IDLOG

String private final

The module identifier used by the logger.

Default: [controller_user]

logger

Object private

The logger. It must have at least three methods: info, warn and error.

Default: console

users

Object private

The list of the user objects. The keys is the user identification and the value is a User object.

Default: {}

Events

endpointPresenceChanged

Fired when the presence of an endpoint of the user changes.

Event Payload:

  • username String

    The username of the endpoint owner

  • endpointType String

    The type of the updated endpoint

  • endpoint Object

    The updated endpoint object of the user ..

usersReady

Fired when the creation of the User objects is completed.