7f748cff43a5fddc79b972e58b1ad51834b21fe4
[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 _0x43a2=['request\x20sent','debug','VoicePrefix,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','util','moment','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','socket.io-emitter','redis','./voicePrefix.socket','register','request','then','info','VoicePrefix,\x20%s,\x20%s'];(function(_0x2f196c,_0x4317ca){var _0x27191d=function(_0x124ba2){while(--_0x124ba2){_0x2f196c['push'](_0x2f196c['shift']());}};_0x27191d(++_0x4317ca);}(_0x43a2,0xd0));var _0x243a=function(_0x1a85fa,_0x17eea7){_0x1a85fa=_0x1a85fa-0x0;var _0x342d33=_0x43a2[_0x1a85fa];return _0x342d33;};'use strict';var _=require('lodash');var util=require(_0x243a('0x0'));var moment=require(_0x243a('0x1'));var BPromise=require(_0x243a('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x243a('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x243a('0x4'));var logger=require(_0x243a('0x5'))(_0x243a('0x6'));var config=require(_0x243a('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x243a('0x8')]['http']({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x243a('0x9'))(new Redis(config[_0x243a('0xa')]));require(_0x243a('0xb'))[_0x243a('0xc')](socket);function respondWithRpcPromise(_0x39b0fc,_0x41a114,_0x5a1f51){return new BPromise(function(_0x497be7,_0x195162){return client[_0x243a('0xd')](_0x39b0fc,_0x5a1f51)[_0x243a('0xe')](function(_0x372eb8){logger[_0x243a('0xf')](_0x243a('0x10'),_0x41a114,_0x243a('0x11'));logger[_0x243a('0x12')](_0x243a('0x13'),_0x41a114,_0x243a('0x11'),JSON[_0x243a('0x14')](_0x372eb8));if(_0x372eb8[_0x243a('0x15')]){if(_0x372eb8[_0x243a('0x15')][_0x243a('0x16')]===0x1f4){logger[_0x243a('0x15')]('VoicePrefix,\x20%s,\x20%s',_0x41a114,_0x372eb8[_0x243a('0x15')][_0x243a('0x17')]);return _0x195162(_0x372eb8[_0x243a('0x15')]['message']);}logger[_0x243a('0x15')](_0x243a('0x10'),_0x41a114,_0x372eb8[_0x243a('0x15')][_0x243a('0x17')]);return _0x497be7(_0x372eb8['error']['message']);}else{logger[_0x243a('0xf')](_0x243a('0x10'),_0x41a114,_0x243a('0x11'));_0x497be7(_0x372eb8['result'][_0x243a('0x17')]);}})[_0x243a('0x18')](function(_0xf4cdb8){logger[_0x243a('0x15')](_0x243a('0x10'),_0x41a114,_0xf4cdb8);_0x195162(_0xf4cdb8);});});}