Built motion from commit (unavailable).|2.5.4
[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 _0x8ed9=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','redis','localhost','socket.io-emitter','./voiceExtension.socket','register','request','then','VoiceExtension,\x20%s,\x20%s','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','info','result','VoiceExtension','findAll','options','raw','where','map','include','model','attributes','GetVoiceExtension','stringify','catch','lodash','util'];(function(_0x42f57c,_0x579a36){var _0x30ea57=function(_0x4d149e){while(--_0x4d149e){_0x42f57c['push'](_0x42f57c['shift']());}};_0x30ea57(++_0x579a36);}(_0x8ed9,0x9a));var _0x98ed=function(_0x27998f,_0x3caf38){_0x27998f=_0x27998f-0x0;var _0x21b0ad=_0x8ed9[_0x27998f];return _0x21b0ad;};'use strict';var _=require(_0x98ed('0x0'));var util=require(_0x98ed('0x1'));var moment=require('moment');var BPromise=require(_0x98ed('0x2'));var rs=require(_0x98ed('0x3'));var fs=require('fs');var Redis=require(_0x98ed('0x4'));var db=require(_0x98ed('0x5'))['db'];var utils=require(_0x98ed('0x6'));var logger=require(_0x98ed('0x7'))(_0x98ed('0x8'));var config=require('../../config/environment');var jayson=require(_0x98ed('0x9'));var client=jayson['client'][_0x98ed('0xa')]({'port':0x232a});config[_0x98ed('0xb')]=_['defaults'](config[_0x98ed('0xb')],{'host':_0x98ed('0xc'),'port':0x18eb});var socket=require(_0x98ed('0xd'))(new Redis(config[_0x98ed('0xb')]));require(_0x98ed('0xe'))[_0x98ed('0xf')](socket);function respondWithRpcPromise(_0x3e65aa,_0x5987ea,_0x420a94){return new BPromise(function(_0x189c5b,_0x4b638b){return client[_0x98ed('0x10')](_0x3e65aa,_0x420a94)[_0x98ed('0x11')](function(_0x3c841e){logger['info'](_0x98ed('0x12'),_0x5987ea,'request\x20sent');logger[_0x98ed('0x13')](_0x98ed('0x14'),_0x5987ea,_0x98ed('0x15'),JSON['stringify'](_0x3c841e));if(_0x3c841e[_0x98ed('0x16')]){if(_0x3c841e['error'][_0x98ed('0x17')]===0x1f4){logger[_0x98ed('0x16')](_0x98ed('0x12'),_0x5987ea,_0x3c841e[_0x98ed('0x16')][_0x98ed('0x18')]);return _0x4b638b(_0x3c841e['error'][_0x98ed('0x18')]);}logger['error']('VoiceExtension,\x20%s,\x20%s',_0x5987ea,_0x3c841e['error'][_0x98ed('0x18')]);return _0x189c5b(_0x3c841e['error']['message']);}else{logger[_0x98ed('0x19')](_0x98ed('0x12'),_0x5987ea,_0x98ed('0x15'));_0x189c5b(_0x3c841e[_0x98ed('0x1a')][_0x98ed('0x18')]);}})['catch'](function(_0x5ab6fc){logger['error'](_0x98ed('0x12'),_0x5987ea,_0x5ab6fc);_0x4b638b(_0x5ab6fc);});});}exports['GetVoiceExtension']=function(_0x10b1c3){var _0x3b5d2e=this;return new Promise(function(_0x105a63,_0x3ddd33){return db[_0x98ed('0x1b')][_0x98ed('0x1c')]({'raw':_0x10b1c3[_0x98ed('0x1d')]?_0x10b1c3[_0x98ed('0x1d')][_0x98ed('0x1e')]===undefined?!![]:![]:!![],'where':_0x10b1c3[_0x98ed('0x1d')]?_0x10b1c3['options'][_0x98ed('0x1f')]||null:null,'attributes':_0x10b1c3[_0x98ed('0x1d')]?_0x10b1c3[_0x98ed('0x1d')]['attributes']||null:null,'limit':_0x10b1c3[_0x98ed('0x1d')]?_0x10b1c3['options']['limit']||null:null,'include':_0x10b1c3['options']?_0x10b1c3['options']['include']?_[_0x98ed('0x20')](_0x10b1c3['options'][_0x98ed('0x21')],function(_0x987fc5){return{'model':db[_0x987fc5[_0x98ed('0x22')]],'as':_0x987fc5['as'],'attributes':_0x987fc5[_0x98ed('0x23')],'include':_0x987fc5[_0x98ed('0x21')]?_[_0x98ed('0x20')](_0x987fc5[_0x98ed('0x21')],function(_0x52c22e){return{'model':db[_0x52c22e[_0x98ed('0x22')]],'as':_0x52c22e['as'],'attributes':_0x52c22e['attributes'],'include':_0x52c22e['include']?_[_0x98ed('0x20')](_0x52c22e[_0x98ed('0x21')],function(_0x59f353){return{'model':db[_0x59f353[_0x98ed('0x22')]],'as':_0x59f353['as'],'attributes':_0x59f353[_0x98ed('0x23')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x607a34){logger[_0x98ed('0x19')]('GetVoiceExtension',_0x10b1c3);logger['debug'](_0x98ed('0x24'),_0x10b1c3,JSON[_0x98ed('0x25')](_0x607a34));_0x105a63(_0x607a34);})[_0x98ed('0x26')](function(_0x2a6fad){logger[_0x98ed('0x16')](_0x98ed('0x24'),_0x2a6fad[_0x98ed('0x18')],_0x10b1c3);_0x3ddd33(_0x3b5d2e[_0x98ed('0x16')](0x1f4,_0x2a6fad[_0x98ed('0x18')]));});});};