API Docs for:
Show:

offhour Class

Module: offhour

Provides the offhour functionalities.

Methods

convertWavToAsteriskFormat

(
  • filename
  • filepathToConvert
  • cb
)
private

Convert a wav file to an asterisk suitable format.

Parameters:

  • filename String

    The final wav filename

  • filepathToConvert String

    The path of the wav file to be converted

  • cb Function

    The callback function

deleteAnnouncement

(
  • id
  • cb
)

Delete the specified audio announcement.

Parameters:

  • id String

    The announcement identifier

  • cb Function

    The callback function

enableAnnouncement

(
  • data
  • cb
)

Enable the recorded audio file for announcement. It moves temporary file to the correct destination.

Parameters:

  • data Object
    • user String

      The user who requested the operation

    • privacy String

      The privacy for audio file for announcement

    • tempFilename String

      The temporary file name given by the upload service

  • cb Function

    The callback function

getAdminInboundRoutes

(
  • cb
)

Returns all the inbound routes.

Parameters:

  • cb Function

    The callback function

getAdvancedInboundRoutes

(
  • username
  • cb
)

Returns the inbound routes of the user and the generics.

Parameters:

  • username String

    The user who requested the operation

  • cb Function

    The callback function

getAllInboundRoutes

(
  • [username]
  • param
  • cb
)

Returns direct did of the user and all other generic inbound routes or returns only the direct dids of the user or return all inbound routes based on the "param" values.

Parameters:

  • [username] String optional

    The user who requested the operation

  • param String

    ("all" | "advanced" | "basic")

  • cb Function

    The callback function

getAnnouncementFileContent

(
  • id
  • cb
)

Reads the audio file of announcement using base64 encoding and returns the content in the callback.

Parameters:

  • id String

    The announcement identifier

  • cb Function

    The callback function

getAnnouncementFilePath

(
  • id
  • cb
)

Return the filepath of the announcement audio file.

Parameters:

  • id String

    The announcement identifier

  • cb Function

    The callback function

getFilenameOfAudioFileForAnnouncement

(
  • username
  • fileExt
)
String private

Returns the name of the audio file for announcement.

Parameters:

  • username String

    The name of the user

  • fileExt String

    The extension of the file

Returns:

String:

The name of audio file for announcement.

getUserInboundRoutes

(
  • username
  • cb
)

Returns the inbound routes of the user.

Parameters:

  • username String

    The user who requested the operation

  • cb Function

    The callback function

listAllAnnouncement

(
  • cb
)

Returns all audio file for announcements.

Parameters:

  • cb Function

    The callback function

listAllPublicAndUserPrivateAnnouncement

(
  • username
  • cb
)

Returns all public and user private audio file for announcements.

Parameters:

  • username String

    The user who requested the operation

  • cb Function

    The callback function

listUserAnnouncement

(
  • username
  • cb
)

Returns all audio file for announcements of the specified user.

Parameters:

  • username String

    The user who requested the operation

  • cb Function

    The callback function

modifyAnnouncement

(
  • data
  • cb
)

Modify data about the specified announcement.

Parameters:

  • data Object
    • id String

      The announcement identifier

    • [privacy] String optional

      The announcement visibility

    • [description] String optional

      The announcement description

  • cb Function

    The callback function

recordAnnouncement

(
  • username
  • cb
)

Record new audio file for announcement.

Parameters:

  • username String

    The user who reqeusted the recording

  • cb Function

    The callback function

setCompAstProxy

(
  • comp
)

Set the module to be used for asterisk proxy functionalities.

Parameters:

  • comp Object

    The asterisk proxy module.

setCompConfigManager

(
  • comp
)

Set the module to be used for config manager functionalities.

Parameters:

  • comp Object

    The config manager module.

setCompDbconn

(
  • comp
)

Set the module to be used for database functionalities.

Parameters:

  • comp Object

    The dbconn module.

setCompUser

(
  • comp
)

Set the module to be used for user functionalities.

Parameters:

  • comp Object

    The user module.

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.

setOffhour

(
  • data
  • cb
)

Set a offhour service. It provides all types of setting using the optional parameters.

Parameters:

  • data Object
    • enabled String

      ("always" | "period" | "never")

    • username String

      The name of the user

    • calledIdNum String

      The called number of the inbound route

    • callerIdNum String

      The caller number of the inbound route

    • [startDate] String optional

      The start date of the period (YYYYMMDD)

    • [startTime] String optional

      The start time of the period (HHmmss)

    • [endDate] String optional

      The end date of the period (YYYYMMDD)

    • [endTime] String optional

      The end time of the period (HHmmss)

    • [action] String optional

      The offhour service action: ("audiomsg" | "audiomsg_voicemail" | "redirect")

    • [redirectTo] String optional

      The destination to use with "action" = "redirect"

    • [voicemailId] String optional

      The voicemail destination to use with "action" = "audiomsg_voicemail"

    • [announcementId] String optional

      Offhour audio announcement identifier to use with "action" = "audiomsg"

  • cb Function

    The callback function

storeDBAudioFileAnnouncement

(
  • data
  • destPath
  • cb
)

Store an entry in "offhour_files" db table for a new audio announcement.

Parameters:

  • data Object
    • user String

      The user who requested the operation

    • privacy String

      The privacy for audio file for announcement

    • description String

      The description of the announcement

  • destPath String

    The destinatino audio file path

  • cb Function

    The callback function

storeMp3Announcement

(
  • data
  • cb
)

Store mp3 audio file for announcement into "audioAnnouncementPath" directory.

Parameters:

  • data Object
    • user String

      The user who requested the operation

    • privacy String

      The privacy for audio file for announcement

    • description String

      The description of the announcement

    • audio_content String

      The audio file content base64 encoded

  • cb Function

    The callback function

storeWavAnnouncement

(
  • data
  • cb
)

Store wav audio file for announcement into "audioAnnouncementPath" directory.

Parameters:

  • data Object
    • user String

      The user who requested the operation

    • privacy String

      The privacy for audio file for announcement

    • description String

      The description of the announcement

    • audio_content String

      The audio file content base64 encoded

  • cb Function

    The callback function

uploadAnnouncement

(
  • data
  • cb
)

Upload audio file for announcement. Store the file into "audioAnnouncementPath" directory.

Parameters:

  • data Object
    • user String

      The user who requested the operation

    • privacy String

      The privacy for audio file for announcement

    • description String

      The description of the announcement

    • audio_content String

      The audio file content base64 encoded

  • cb Function

    The callback function

verifyAdvancedInboundRouteOfUser

(
  • username
  • calledIdNum
  • callerIdNum
  • The
)

Verify if the inbound route involves an extension of the user or it is generic.

Parameters:

  • username String

    The username

  • calledIdNum String

    The called number of the inbound route

  • callerIdNum String

    The caller number of the inbound route

  • The Function

    callback function

verifyAudioMessagePermission

(
  • username
  • id
  • The
)

Verify that the audio message is owned by the user or has the "public" visibility.

Parameters:

  • username String

    The username

  • id String

    The audio message id

  • The Function

    callback function

verifyBasicInboundRouteOfUser

(
  • username
  • calledIdNum
  • callerIdNum
  • The
)

Verify if the inbound route involves an extension of the user.

Parameters:

  • username String

    The username

  • calledIdNum String

    The called number of the inbound route

  • callerIdNum String

    The caller number of the inbound route

  • The Function

    callback function

Properties

AUDIO_ASTERISK_PATH

String private final

The destination path of asterisk audio files.

Default: "/var/lib/asterisk/sounds"

AUDIO_DIRNAME

String private final

The destination directory name of audio file for announcements.

Default: "nethcti"

AUDIO_RECORDED_PATH

String private final

The destination path of recorded audio file for announcements.

Default: "/var/spool/asterisk/tmp"

audioAnnouncementPath

String private

The destination path of audio file for announcements. It is made joining AUDIO_ASTERISK_PATH and AUDIO_DIRNAME;

compAstProxy

Object private

The asterisk proxy module.

compConfigManager

Object private

The config manager module.

compDbconn

Object private

The dbconn module.

compUser

Object private

The user module.

FILEEXT_AUDIO_ANNOUNCEMENT

String private final

The extension of the audio file for announcements.

Default: "wav"

IDLOG

String private final

The module identifier used by the logger.

Default: [offhour]

logger

Object private

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

Default: console

MPG123_SCRIPT_PATH

String private

The path of the mpg123 script.

SOX_SCRIPT_PATH

String private

The path of the sox script.