5719cbdc07f4dd4c7513a54fd1df514c2ee33c43
[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 _0xa730=['error','VoicePrefix,\x20%s,\x20%s','message','result','catch','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','then','info','request\x20sent','debug','VoicePrefix,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x2a05dd,_0x32b37d){var _0x5b7cee=function(_0x3c64a1){while(--_0x3c64a1){_0x2a05dd['push'](_0x2a05dd['shift']());}};_0x5b7cee(++_0x32b37d);}(_0xa730,0x11d));var _0x0a73=function(_0x3c7238,_0x44dc8c){_0x3c7238=_0x3c7238-0x0;var _0x45e4e9=_0xa730[_0x3c7238];return _0x45e4e9;};'use strict';var _=require(_0x0a73('0x0'));var util=require(_0x0a73('0x1'));var moment=require(_0x0a73('0x2'));var BPromise=require('bluebird');var rs=require(_0x0a73('0x3'));var fs=require('fs');var Redis=require(_0x0a73('0x4'));var db=require(_0x0a73('0x5'))['db'];var utils=require(_0x0a73('0x6'));var logger=require(_0x0a73('0x7'))(_0x0a73('0x8'));var config=require(_0x0a73('0x9'));var jayson=require(_0x0a73('0xa'));var client=jayson[_0x0a73('0xb')][_0x0a73('0xc')]({'port':0x232a});config[_0x0a73('0xd')]=_[_0x0a73('0xe')](config[_0x0a73('0xd')],{'host':_0x0a73('0xf'),'port':0x18eb});var socket=require(_0x0a73('0x10'))(new Redis(config['redis']));require('./voicePrefix.socket')['register'](socket);function respondWithRpcPromise(_0x27f5fe,_0xe0b652,_0x55a15c){return new BPromise(function(_0xbfe917,_0x39aa38){return client['request'](_0x27f5fe,_0x55a15c)[_0x0a73('0x11')](function(_0x51a626){logger[_0x0a73('0x12')]('VoicePrefix,\x20%s,\x20%s',_0xe0b652,_0x0a73('0x13'));logger[_0x0a73('0x14')](_0x0a73('0x15'),_0xe0b652,_0x0a73('0x13'),JSON[_0x0a73('0x16')](_0x51a626));if(_0x51a626[_0x0a73('0x17')]){if(_0x51a626[_0x0a73('0x17')]['code']===0x1f4){logger['error'](_0x0a73('0x18'),_0xe0b652,_0x51a626[_0x0a73('0x17')][_0x0a73('0x19')]);return _0x39aa38(_0x51a626[_0x0a73('0x17')][_0x0a73('0x19')]);}logger[_0x0a73('0x17')](_0x0a73('0x18'),_0xe0b652,_0x51a626[_0x0a73('0x17')]['message']);return _0xbfe917(_0x51a626['error'][_0x0a73('0x19')]);}else{logger[_0x0a73('0x12')](_0x0a73('0x18'),_0xe0b652,'request\x20sent');_0xbfe917(_0x51a626[_0x0a73('0x1a')][_0x0a73('0x19')]);}})[_0x0a73('0x1b')](function(_0x1bc736){logger['error'](_0x0a73('0x18'),_0xe0b652,_0x1bc736);_0x39aa38(_0x1bc736);});});}