10de39839f03efead74c4e33e46ec13fbbbdff89
[motion2.git] / server / api / voicePrefix / voicePrefix.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xcaf2=['debug','VoicePrefix,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','redis','defaults','localhost','./voicePrefix.socket','register','request','info','VoicePrefix,\x20%s,\x20%s','request\x20sent'];(function(_0x58feab,_0xd0bfd8){var _0x1b87e6=function(_0x3d939f){while(--_0x3d939f){_0x58feab['push'](_0x58feab['shift']());}};_0x1b87e6(++_0xd0bfd8);}(_0xcaf2,0x8a));var _0x2caf=function(_0x37ef38,_0x2cfe4e){_0x37ef38=_0x37ef38-0x0;var _0x499daa=_0xcaf2[_0x37ef38];return _0x499daa;};'use strict';var _=require(_0x2caf('0x0'));var util=require('util');var moment=require(_0x2caf('0x1'));var BPromise=require(_0x2caf('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x2caf('0x3'));var db=require(_0x2caf('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x2caf('0x5'))('rpc');var config=require(_0x2caf('0x6'));var jayson=require(_0x2caf('0x7'));var client=jayson[_0x2caf('0x8')]['http']({'port':0x232a});config[_0x2caf('0x9')]=_[_0x2caf('0xa')](config[_0x2caf('0x9')],{'host':_0x2caf('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x2caf('0x9')]));require(_0x2caf('0xc'))[_0x2caf('0xd')](socket);function respondWithRpcPromise(_0x1ff859,_0x219d0f,_0x438434){return new BPromise(function(_0x1b20e3,_0x3b5631){return client[_0x2caf('0xe')](_0x1ff859,_0x438434)['then'](function(_0xd56396){logger[_0x2caf('0xf')](_0x2caf('0x10'),_0x219d0f,_0x2caf('0x11'));logger[_0x2caf('0x12')](_0x2caf('0x13'),_0x219d0f,_0x2caf('0x11'),JSON[_0x2caf('0x14')](_0xd56396));if(_0xd56396['error']){if(_0xd56396[_0x2caf('0x15')][_0x2caf('0x16')]===0x1f4){logger['error']('VoicePrefix,\x20%s,\x20%s',_0x219d0f,_0xd56396['error'][_0x2caf('0x17')]);return _0x3b5631(_0xd56396['error'][_0x2caf('0x17')]);}logger[_0x2caf('0x15')](_0x2caf('0x10'),_0x219d0f,_0xd56396[_0x2caf('0x15')]['message']);return _0x1b20e3(_0xd56396[_0x2caf('0x15')]['message']);}else{logger[_0x2caf('0xf')]('VoicePrefix,\x20%s,\x20%s',_0x219d0f,'request\x20sent');_0x1b20e3(_0xd56396[_0x2caf('0x18')]['message']);}})[_0x2caf('0x19')](function(_0x9c7302){logger['error'](_0x2caf('0x10'),_0x219d0f,_0x9c7302);_0x3b5631(_0x9c7302);});});}