API Docs for:
Show:

controller_user Class

Module: user

Provides the user functionalities.

Item Index

Methods

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

(
  • path
)
private

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

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

deleteSetting

(
  • username
  • prop
  • cb
)

Delete a single user setting from the database.

Parameters:

  • username String

    The username

  • prop String

    The property to be deleted

  • cb Function

    The callback function

deleteSettings

(
  • username
  • cb
)

Delete all the user settings from the database.

Parameters:

  • username String

    The username

  • cb Function

    The callback function

disableCfbExten

(
  • ext
)
Function

Disable CFB for the extension.

Parameters:

  • ext String

    The extension identifier

Returns:

Function:

The function to be called by setPresenceOnBusy.

disableCfbVmExten

(
  • ext
)
Function

Disable CFB vm for the extension.

Parameters:

  • ext String

    The extension identifier

Returns:

Function:

The function to be called by setPresenceOnBusy.

disableCfExten

(
  • ext
)
Function

Disable CF for the extension.

Parameters:

  • ext String

    The extension identifier

Returns:

Function:

The function to be called by setPresence.

disableCfuExten

(
  • ext
)
Function

Disable CFU for the extension.

Parameters:

  • ext String

    The extension identifier

Returns:

Function:

The function to be called by setPresenceOnUnavailable.

disableCfuVmExten

(
  • ext
)
Function

Disable CFU vm for the extension.

Parameters:

  • ext String

    The extension identifier

Returns:

Function:

The function to be called by setPresenceOnUnavailable.

disableCfVmExten

(
  • ext
)
Function

Disable CFVM for the extension.

Parameters:

  • ext String

    The extension identifier

Returns:

Function:

The function to be called by setPresence.

disableDndExten

(
  • ext
)
Function

Disable DND for the extension.

Parameters:

  • ext String

    The extension identifier

Returns:

Function:

The function to be called by setPresence.

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

enableCfbCellphoneExten

(
  • ext
  • username
)
Function

Enable CFB to cellphone for the extension.

Parameters:

  • ext String

    The extension identifier

  • username String

    The username

Returns:

Function:

The function to be called by setPresenceOnBusy.

enableCfbExten

(
  • ext
  • username
  • destination
)
Function

Enable CFB to a destination number for the extension.

Parameters:

  • ext String

    The extension identifier

  • username String

    The username

  • destination String

    The destination number of call forward busy

Returns:

Function:

The function to be called by setPresenceOnBusy.

enableCfbNumberExten

(
  • ext
  • username
  • destination
)
Function

Enable CFB to a destination number for the extension.

Parameters:

  • ext String

    The extension identifier

  • username String

    The username

  • destination String

    The destination number of call forward on busy

Returns:

Function:

The function to be called by setPresenceOnBusy.

enableCfbVmExten

(
  • ext
  • username
)
Function

Enable CFB VM for the extension.

Parameters:

  • ext String

    The extension identifier

  • username String

    The username

Returns:

Function:

The function to be called by setPresenceOnBusy.

enableCfCellphoneExten

(
  • ext
  • username
)
Function

Enable CF to cellphone for the extension.

Parameters:

  • ext String

    The extension identifier

  • username String

    The username

Returns:

Function:

The function to be called by setPresence.

enableCfNumberExten

(
  • ext
  • username
  • destination
)
Function

Enable CF to a destination number for the extension.

Parameters:

  • ext String

    The extension identifier

  • username String

    The username

  • destination String

    The destination number of call forward

Returns:

Function:

The function to be called by setPresence.

enableCfuCellphoneExten

(
  • ext
  • username
)
Function

Enable CFU to cellphone for the extension.

Parameters:

  • ext String

    The extension identifier

  • username String

    The username

Returns:

Function:

The function to be called by setPresenceOnUnavailable.

enableCfuExten

(
  • ext
  • username
  • destination
)
Function

Enable CFU to a destination number for the extension.

Parameters:

  • ext String

    The extension identifier

  • username String

    The username

  • destination String

    The destination number of call forward unavailable

Returns:

Function:

The function to be called by setPresenceOnUnavailable.

enableCfuNumberExten

(
  • ext
  • username
  • destination
)
Function

Enable CFU to a destination number for the extension.

Parameters:

  • ext String

    The extension identifier

  • username String

    The username

  • destination String

    The destination number of call forward on unavailable

Returns:

Function:

The function to be called by setPresenceOnUnavailable.

enableCfuVmExten

(
  • ext
  • username
)
Function

Enable CFU VM for the extension.

Parameters:

  • ext String

    The extension identifier

  • username String

    The username

Returns:

Function:

The function to be called by setPresenceOnUnavailable.

enableCfVmExten

(
  • ext
  • username
)
Function

Enable CFVM for the extension.

Parameters:

  • ext String

    The extension identifier

  • username String

    The username

Returns:

Function:

The function to be called by setPresence.

enableDndExten

(
  • ext
)
Function

Enable DND for the extension.

Parameters:

  • ext String

    The extension identifier

Returns:

Function:

The function to be called by setPresence.

evtExtenCfbChanged

(
  • data
)
private

Handler for the extenCfbChanged event emitted by astproxy component. This event is generated from asterisk and so it could be generated from physical phone using freepbx features code (*90 to enable and *91 to disable). If the event is cfb off, it check for all extensions of the user and disable cfb for each of them. If the event is cfb on and it does not involve the main extension, it enbales cfb for the main extension of the user.

Parameters:

  • data Object

    The data received by the event

evtExtenCfChanged

(
  • data
)
private

Handler for the extenCfChanged event emitted by astproxy component. This event is generated from asterisk and so it could be generated from physical phone dnd setting using freepbx features code (*72 to enable and *73 to disable). If the event is cf off, it check for all extensions of the user and disable cf for each of them. If the event is cf on and it does not involve the main extension, it enbales cf for the main extension of the user.

Parameters:

  • data Object

    The data received by the event

evtExtenCfuChanged

(
  • data
)
private

Handler for the extenCfuChanged event emitted by astproxy component. This event is generated from asterisk and so it could be generated from physical phone using freepbx features code (*52 to enable and *53 to disable). If the event is cfu off, it check for all extensions of the user and disable cfu for each of them. If the event is cfu on and it does not involve the main extension, it enbales cfu for the main extension of the user.

Parameters:

  • data Object

    The data received by the event

evtExtenCfVmChanged

(
  • data
)
private

Handler for the extenCfVmChanged event emitted by astproxy component. This event is generated from asterisk and so it could be generated from physical phone dnd setting using freepbx features code (*72vmu to enable and *73 to disable). If the event is cfvm off, it check for all extensions of the user and disable cfvm for each of them. If the event is cfvm on and it does not involve the main extension, it enbales cfvm for the main extension of the user.

Parameters:

  • data Object

    The data received by the event

evtExtenDndChanged

(
  • data
)
private

Handler for the extenDndChanged event emitted by astproxy component. This event is generated from asterisk and so it could be generated from physical phone dnd setting using freepbx features code (*78 to enable and *79 to disable). If the event is dnd off, it check for all extensions of the user and disable dnd for each of them. If the event is dnd on and it does not involve the main extension, it enbales dnd for the main extension of the user.

Parameters:

  • data Object

    The data received by the event

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.

getAllEndpointsVoicemail

(
  • username
)
Object

Returns all the voicemail endpoints of the user.

Parameters:

  • username String

    The username

Returns:

Object:

Returns all the voicemail endpoints of the user.

getAllUserExtensions

(
  • username
)
Array

Returns all extension of a user.

Parameters:

  • username String

    The username of the user to be set

Returns:

Array:

All the extensions of a 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.

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.

getEndpointMainExtension

(
  • username
)
Object

Get the main extension endpoint of the user.

Parameters:

  • username String

    The name of the user

Returns:

Object:

The main extension endpoint.

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.

getEndpointVoicemail

(
  • username
)
Object

Get the voicemail endpoint of the user.

Parameters:

  • username String

    The name of the user

Returns:

Object:

The voicemail endpoint.

getParamUrl

(
  • username
  • profileId
  • cb
)

Return the parameterized URL for the use profile.

Parameters:

  • username String

    The username

  • profileId String

    The id of the user profile

  • cb Function

    The callback

getPhoneWebPass

(
  • username
  • exten
)
Object

Returns the phone password to be used to invoce HTTP apis.

Parameters:

  • username String

    The username

  • exten String

    The extension identifier

Returns:

Object:

The phone web password used to invoke HTTP apis.

getPhoneWebUser

(
  • username
  • exten
)
Object

Returns the phone username to be used to invoce HTTP apis.

Parameters:

  • username String

    The username

  • exten String

    The extension identifier

Returns:

Object:

The phone web username used to invoke HTTP apis.

getPresence

(
  • username
)
String

Get the user presence status.

Parameters:

  • username String

    The username

Returns:

String:

The presence status.

getPresenceCallforwardTo

(
  • username
)
String

Get the destination of the call forward user presence status.

Parameters:

  • username String

    The username

Returns:

String:

The destination number.

getPresenceList

(
  • username
)
Array

Return the list of all possible user presence.

Parameters:

  • username String

    The username

Returns:

Array:

All the possible presence of the user.

getPresenceListOnBusy

(
  • username
)
Array

Return the list of all possible conditional user presence on busy.

Parameters:

  • username String

    The username

Returns:

Array:

All the possible conditional presence of the user on busy.

getPresenceListOnUnavailable

(
  • username
)
Array

Return the list of all possible conditional user presence on unavailable.

Parameters:

  • username String

    The username

Returns:

Array:

All the possible conditional presence of the user on unavailable.

getPresenceOnBusy

(
  • username
)
String

Get the conditional user presence status on busy.

Parameters:

  • username String

    The username

Returns:

String:

The conditional presence status on busy.

getPresenceOnBusyCallforwardTo

(
  • username
)
String

Get the destination of the call forward on busy user presence status.

Parameters:

  • username String

    The username

Returns:

String:

The destination number.

getPresenceOnUnavailable

(
  • username
)
String

Get the conditional user presence status on unavailable.

Parameters:

  • username String

    The username

Returns:

String:

The conditional presence status on unavailable.

getPresenceOnUnavailableCallforwardTo

(
  • username
)
String

Get the destination of the call forward on unavailable user presence status.

Parameters:

  • username String

    The username

Returns:

String:

The destination number.

getQueueIds

(
  • username
)
Array private

Returns the identifiers of the queues to which the user belongs.

Parameters:

  • username String

    The username

Returns:

Array:

The queue identifiers of the user.

getUserFromExten

(
  • extenId
)
String private

Returns the username that has the extension associated.

Parameters:

  • extenId String

    The identifier of the extension

Returns:

String:

The name of the user that has the extension.

getUserInfoJSON

(
  • username
)
String

Get the user information in JSON format.

Parameters:

  • username String

    The username

Returns:

String:

The user information 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.

Returns:

Object:

The list of all the usernames with their names.

getUserSettings

(
  • username
  • cb
)

Returns the user settings from the database.

Parameters:

  • username String

    The username

  • cb Function

    The callback function

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.

getUserUsingEndpointExtension

(
  • exten
)
String

Returns the user associated with the specified extension endpoint.

Parameters:

  • exten String

    The extension endpoint identifier

Returns:

String:

The username associated with the specified extension 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.

initializeAstProxyListeners

() private

Initialize the listeners for asterisk proxy component.

initializeEndpointsUsersByJSON

(
  • json
)
private

Adds the endpoint objects to the user by json configuration.

Parameters:

  • json Object

    The JSON configuration

initializeUsersPresence

() private

Initialize the presence of all users.

isExtenWebrtc

(
  • exten
)
Boolean

Checks if the extension is of webrtc type.

Parameters:

  • exten String

    The extension identifier

Returns:

Boolean:

True if the extension is of webrtc type.

isMainExtension

(
  • extenId
)
Boolean private

Check if the extension is a main extension.

Parameters:

  • extenId String

    The identifier of the extension to be checked

Returns:

Boolean:

True if the extension is a main extension of a user

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.

reload

() private

Reload the component.

reset

() private

Reload the component.

saveSettings

(
  • username
  • data
  • cb
)

Save the user settings into the database.

Parameters:

  • username String

    The username

  • data Object

    The JSON data object

  • cb Function

    The callback function

setCompAstProxy

(
  • comp
)

Set the asterisk proxy architect component.

Parameters:

  • comp Object

    The asterisk proxy architect component.

setCompDbconn

(
  • comp
)

Set the dbconn architect component.

Parameters:

  • comp Object

    The dbconn architect component.

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.

setMobilePhoneNumber

(
  • username
  • pnumber
  • cb
)

Associate the mobile phone number to the user.

Parameters:

  • username String

    The username of the user to be set

  • pnumber String

    The mobile phone number

  • cb Function

    The callback function

setPresence

(
  • param
  • cb
)

Set the user presence status.

Parameters:

  • param Object
    • username String

      The username of the user to be set

    • status String

      The presence status

    • [destination] String optional

      The destination of "callforward" status

  • cb Function

    The callback function

setPresenceOnBusy

(
  • param
  • cb
)

Set the user presence status on busy.

Parameters:

  • param Object
    • username String

      The username of the user to be set

    • status String

      The presence status on busy

    • [destination] String optional

      The destination of "callforward" status on busy

  • cb Function

    The callback function

setPresenceOnUnavailable

(
  • param
  • cb
)

Set the user presence status on unavailable.

Parameters:

  • param Object
    • username String

      The username of the user to be set

    • status String

      The presence status on unavailable

    • [destination] String optional

      The destination of "callforward" status on unavailable

  • cb Function

    The callback function

updateCondUserPresence

(
  • username
)
private

Update the conditional user presence.

Parameters:

  • username String

    The username to be updated

updateUserPresence

(
  • username
)
private

Update the user presence.

Parameters:

  • username String

    The username to be updated

updateUserPresenceOnBusy

(
  • username
)
private

Update the conditional user presence on busy.

Parameters:

  • username String

    The username to be updated

updateUserPresenceOnUnavailable

(
  • username
)
private

Update the conditional user presence on unavailable.

Parameters:

  • username String

    The username to be updated

Properties

compAstProxy

Object private

The asterisk proxy architect component.

compDbconn

Object private

The dbconn architect component.

emitter

Object private

The event emitter.

EVT_RELOADED

String

The name of the reloaded event.

Default: "reloaded"

EVT_USER_PRESENCE_CHANGED

String

The name of the user presence changed event.

Default: "userPresenceChanged"

EVT_USER_PROFILE_AVATAR_CHANGED

String

The name of the user profile avatar update event.

Default: "userProfileAvatarUpdate"

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

ready

Boolean private

True if the component has been started. Used to emit EVT_RELOADED instead of EVT_READY

Default: false

users

Object private

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

Default: {}

USERS_CONF_FILEPATH

String private

The configuration file path of the users.

Events

reloaded

Fired when the componente has been reloaded.

userPresenceChanged

Fired when the user presence has changed.

userProfileAvatarChanged

Fired when the client user has changed his own avatar picture.

usersReady

Fired when the creation of the User objects is completed.