85f433c1f1e890eaa5b5db177e16dcbb23e86adb
[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 _0x7804=['message','result','catch','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/environment','http','redis','defaults','socket.io-emitter','register','request','then','request\x20sent','debug','VoicePrefix,\x20%s,\x20%s,\x20%s','stringify','code','VoicePrefix,\x20%s,\x20%s','error'];(function(_0x23f51c,_0x98224d){var _0x5a98be=function(_0x1eadbd){while(--_0x1eadbd){_0x23f51c['push'](_0x23f51c['shift']());}};_0x5a98be(++_0x98224d);}(_0x7804,0xc3));var _0x4780=function(_0x1a4984,_0x530a11){_0x1a4984=_0x1a4984-0x0;var _0x4cc8a6=_0x7804[_0x1a4984];return _0x4cc8a6;};'use strict';var _=require(_0x4780('0x0'));var util=require('util');var moment=require(_0x4780('0x1'));var BPromise=require(_0x4780('0x2'));var rs=require(_0x4780('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x4780('0x4'))['db'];var utils=require(_0x4780('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0x4780('0x6'));var jayson=require('jayson/promise');var client=jayson['client'][_0x4780('0x7')]({'port':0x232a});config[_0x4780('0x8')]=_[_0x4780('0x9')](config[_0x4780('0x8')],{'host':'localhost','port':0x18eb});var socket=require(_0x4780('0xa'))(new Redis(config['redis']));require('./voicePrefix.socket')[_0x4780('0xb')](socket);function respondWithRpcPromise(_0x14be09,_0x2fc8a9,_0x45369b){return new BPromise(function(_0x4af80e,_0x5ca23a){return client[_0x4780('0xc')](_0x14be09,_0x45369b)[_0x4780('0xd')](function(_0x21d3d5){logger['info']('VoicePrefix,\x20%s,\x20%s',_0x2fc8a9,_0x4780('0xe'));logger[_0x4780('0xf')](_0x4780('0x10'),_0x2fc8a9,_0x4780('0xe'),JSON[_0x4780('0x11')](_0x21d3d5));if(_0x21d3d5['error']){if(_0x21d3d5['error'][_0x4780('0x12')]===0x1f4){logger['error'](_0x4780('0x13'),_0x2fc8a9,_0x21d3d5[_0x4780('0x14')][_0x4780('0x15')]);return _0x5ca23a(_0x21d3d5[_0x4780('0x14')]['message']);}logger[_0x4780('0x14')]('VoicePrefix,\x20%s,\x20%s',_0x2fc8a9,_0x21d3d5[_0x4780('0x14')][_0x4780('0x15')]);return _0x4af80e(_0x21d3d5[_0x4780('0x14')][_0x4780('0x15')]);}else{logger['info'](_0x4780('0x13'),_0x2fc8a9,'request\x20sent');_0x4af80e(_0x21d3d5[_0x4780('0x16')][_0x4780('0x15')]);}})[_0x4780('0x17')](function(_0x3af22f){logger['error'](_0x4780('0x13'),_0x2fc8a9,_0x3af22f);_0x5ca23a(_0x3af22f);});});}