d93ccabc0174e9f965a79ddf8dbbd347b4242589
[motion2.git] / server / api / voiceExtension / voiceExtension.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 _0xadf0=['../../mysqldb','../../config/utils','rpc','redis','defaults','socket.io-emitter','register','then','info','VoiceExtension,\x20%s,\x20%s','request\x20sent','VoiceExtension,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetVoiceExtension','findAll','options','raw','where','attributes','limit','map','include','model','debug','stringify','util','moment','bluebird','randomstring','ioredis'];(function(_0x3ff0b0,_0x5b985d){var _0x334054=function(_0x465e40){while(--_0x465e40){_0x3ff0b0['push'](_0x3ff0b0['shift']());}};_0x334054(++_0x5b985d);}(_0xadf0,0x12d));var _0x0adf=function(_0xa9713a,_0x466f35){_0xa9713a=_0xa9713a-0x0;var _0x1c2744=_0xadf0[_0xa9713a];return _0x1c2744;};'use strict';var _=require('lodash');var util=require(_0x0adf('0x0'));var moment=require(_0x0adf('0x1'));var BPromise=require(_0x0adf('0x2'));var rs=require(_0x0adf('0x3'));var fs=require('fs');var Redis=require(_0x0adf('0x4'));var db=require(_0x0adf('0x5'))['db'];var utils=require(_0x0adf('0x6'));var logger=require('../../config/logger')(_0x0adf('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});config[_0x0adf('0x8')]=_[_0x0adf('0x9')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x0adf('0xa'))(new Redis(config[_0x0adf('0x8')]));require('./voiceExtension.socket')[_0x0adf('0xb')](socket);function respondWithRpcPromise(_0x1aac49,_0x5cb4d9,_0x4712d7){return new BPromise(function(_0x169c4c,_0x4d7775){return client['request'](_0x1aac49,_0x4712d7)[_0x0adf('0xc')](function(_0x43cbf5){logger[_0x0adf('0xd')](_0x0adf('0xe'),_0x5cb4d9,_0x0adf('0xf'));logger['debug'](_0x0adf('0x10'),_0x5cb4d9,_0x0adf('0xf'),JSON['stringify'](_0x43cbf5));if(_0x43cbf5[_0x0adf('0x11')]){if(_0x43cbf5['error'][_0x0adf('0x12')]===0x1f4){logger['error'](_0x0adf('0xe'),_0x5cb4d9,_0x43cbf5[_0x0adf('0x11')][_0x0adf('0x13')]);return _0x4d7775(_0x43cbf5[_0x0adf('0x11')][_0x0adf('0x13')]);}logger[_0x0adf('0x11')](_0x0adf('0xe'),_0x5cb4d9,_0x43cbf5[_0x0adf('0x11')]['message']);return _0x169c4c(_0x43cbf5[_0x0adf('0x11')][_0x0adf('0x13')]);}else{logger['info'](_0x0adf('0xe'),_0x5cb4d9,'request\x20sent');_0x169c4c(_0x43cbf5[_0x0adf('0x14')][_0x0adf('0x13')]);}})[_0x0adf('0x15')](function(_0x3170da){logger['error'](_0x0adf('0xe'),_0x5cb4d9,_0x3170da);_0x4d7775(_0x3170da);});});}exports[_0x0adf('0x16')]=function(_0x283f67){var _0x3f8b08=this;return new Promise(function(_0x420c4f,_0x42f1d6){return db['VoiceExtension'][_0x0adf('0x17')]({'raw':_0x283f67[_0x0adf('0x18')]?_0x283f67[_0x0adf('0x18')][_0x0adf('0x19')]===undefined?!![]:![]:!![],'where':_0x283f67['options']?_0x283f67[_0x0adf('0x18')][_0x0adf('0x1a')]||null:null,'attributes':_0x283f67[_0x0adf('0x18')]?_0x283f67['options'][_0x0adf('0x1b')]||null:null,'limit':_0x283f67[_0x0adf('0x18')]?_0x283f67[_0x0adf('0x18')][_0x0adf('0x1c')]||null:null,'include':_0x283f67[_0x0adf('0x18')]?_0x283f67[_0x0adf('0x18')]['include']?_[_0x0adf('0x1d')](_0x283f67[_0x0adf('0x18')][_0x0adf('0x1e')],function(_0x39a337){return{'model':db[_0x39a337[_0x0adf('0x1f')]],'as':_0x39a337['as'],'attributes':_0x39a337[_0x0adf('0x1b')],'include':_0x39a337['include']?_[_0x0adf('0x1d')](_0x39a337[_0x0adf('0x1e')],function(_0x272205){return{'model':db[_0x272205['model']],'as':_0x272205['as'],'attributes':_0x272205['attributes'],'include':_0x272205['include']?_[_0x0adf('0x1d')](_0x272205[_0x0adf('0x1e')],function(_0x364fcf){return{'model':db[_0x364fcf[_0x0adf('0x1f')]],'as':_0x364fcf['as'],'attributes':_0x364fcf[_0x0adf('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x0adf('0xc')](function(_0x19fa54){logger[_0x0adf('0xd')](_0x0adf('0x16'),_0x283f67);logger[_0x0adf('0x20')](_0x0adf('0x16'),_0x283f67,JSON[_0x0adf('0x21')](_0x19fa54));_0x420c4f(_0x19fa54);})[_0x0adf('0x15')](function(_0x366d20){logger[_0x0adf('0x11')]('GetVoiceExtension',_0x366d20[_0x0adf('0x13')],_0x283f67);_0x42f1d6(_0x3f8b08[_0x0adf('0x11')](0x1f4,_0x366d20[_0x0adf('0x13')]));});});};