Built motion from commit 67e5df37.|2.0.66
[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 _0xdace=['../../config/environment','client','http','socket.io-emitter','./voiceExtension.socket','register','info','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','stringify','error','code','VoiceExtension,\x20%s,\x20%s','message','result','catch','GetVoiceExtension','findAll','options','raw','where','attributes','limit','include','map','model','then','lodash','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc'];(function(_0x5dc1dc,_0x2a4676){var _0x248231=function(_0x3752d7){while(--_0x3752d7){_0x5dc1dc['push'](_0x5dc1dc['shift']());}};_0x248231(++_0x2a4676);}(_0xdace,0xc5));var _0xedac=function(_0x50aa2e,_0xfbd6f0){_0x50aa2e=_0x50aa2e-0x0;var _0x5e07f0=_0xdace[_0x50aa2e];return _0x5e07f0;};'use strict';var _=require(_0xedac('0x0'));var util=require('util');var moment=require(_0xedac('0x1'));var BPromise=require(_0xedac('0x2'));var rs=require(_0xedac('0x3'));var fs=require('fs');var db=require('../../mysqldb')['db'];var utils=require(_0xedac('0x4'));var logger=require(_0xedac('0x5'))(_0xedac('0x6'));var config=require(_0xedac('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xedac('0x8')][_0xedac('0x9')]({'port':0x232a});var socket=require(_0xedac('0xa'))({'host':'localhost','port':0x18eb});require(_0xedac('0xb'))[_0xedac('0xc')](socket);function respondWithRpcPromise(_0x162eea,_0x53fa43,_0x27243f){return new BPromise(function(_0x2d6dd1,_0xc98887){return client['request'](_0x162eea,_0x27243f)['then'](function(_0x144368){logger[_0xedac('0xd')]('VoiceExtension,\x20%s,\x20%s',_0x53fa43,'request\x20sent');logger[_0xedac('0xe')](_0xedac('0xf'),_0x53fa43,'request\x20sent',JSON[_0xedac('0x10')](_0x144368));if(_0x144368['error']){if(_0x144368[_0xedac('0x11')][_0xedac('0x12')]===0x1f4){logger[_0xedac('0x11')](_0xedac('0x13'),_0x53fa43,_0x144368[_0xedac('0x11')][_0xedac('0x14')]);return _0xc98887(_0x144368[_0xedac('0x11')][_0xedac('0x14')]);}logger['error'](_0xedac('0x13'),_0x53fa43,_0x144368[_0xedac('0x11')][_0xedac('0x14')]);return _0x2d6dd1(_0x144368[_0xedac('0x11')][_0xedac('0x14')]);}else{logger['info'](_0xedac('0x13'),_0x53fa43,'request\x20sent');_0x2d6dd1(_0x144368[_0xedac('0x15')][_0xedac('0x14')]);}})[_0xedac('0x16')](function(_0xba0c93){logger['error']('VoiceExtension,\x20%s,\x20%s',_0x53fa43,_0xba0c93);_0xc98887(_0xba0c93);});});}exports[_0xedac('0x17')]=function(_0x2adefa){var _0x25fe64=this;return new Promise(function(_0x1500ae,_0x5a5438){return db['VoiceExtension'][_0xedac('0x18')]({'raw':_0x2adefa[_0xedac('0x19')]?_0x2adefa[_0xedac('0x19')][_0xedac('0x1a')]===undefined?!![]:![]:!![],'where':_0x2adefa[_0xedac('0x19')]?_0x2adefa[_0xedac('0x19')][_0xedac('0x1b')]||null:null,'attributes':_0x2adefa[_0xedac('0x19')]?_0x2adefa['options'][_0xedac('0x1c')]||null:null,'limit':_0x2adefa['options']?_0x2adefa[_0xedac('0x19')][_0xedac('0x1d')]||null:null,'include':_0x2adefa['options']?_0x2adefa[_0xedac('0x19')][_0xedac('0x1e')]?_[_0xedac('0x1f')](_0x2adefa[_0xedac('0x19')][_0xedac('0x1e')],function(_0x167d7e){return{'model':db[_0x167d7e['model']],'as':_0x167d7e['as'],'attributes':_0x167d7e[_0xedac('0x1c')],'include':_0x167d7e[_0xedac('0x1e')]?_[_0xedac('0x1f')](_0x167d7e[_0xedac('0x1e')],function(_0x1ff33e){return{'model':db[_0x1ff33e[_0xedac('0x20')]],'as':_0x1ff33e['as'],'attributes':_0x1ff33e[_0xedac('0x1c')],'include':_0x1ff33e[_0xedac('0x1e')]?_[_0xedac('0x1f')](_0x1ff33e[_0xedac('0x1e')],function(_0x4c5566){return{'model':db[_0x4c5566[_0xedac('0x20')]],'as':_0x4c5566['as'],'attributes':_0x4c5566[_0xedac('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xedac('0x21')](function(_0x5dff75){logger[_0xedac('0xd')]('GetVoiceExtension',_0x2adefa);logger['debug'](_0xedac('0x17'),_0x2adefa,JSON[_0xedac('0x10')](_0x5dff75));_0x1500ae(_0x5dff75);})[_0xedac('0x16')](function(_0x14522a){logger['error']('GetVoiceExtension',_0x14522a[_0xedac('0x14')],_0x2adefa);_0x5a5438(_0x25fe64[_0xedac('0x11')](0x1f4,_0x14522a[_0xedac('0x14')]));});});};