7abced92fb1c47c0273042c6b73502fdff66c1e3
[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 _0x01db=['bluebird','randomstring','ioredis','../../config/utils','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./voiceExtension.socket','register','then','info','VoiceExtension,\x20%s,\x20%s','request\x20sent','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','error','code','message','result','GetVoiceExtension','VoiceExtension','findAll','options','raw','where','attributes','limit','include','map','model','stringify','catch','lodash'];(function(_0x28557d,_0x572726){var _0xe70a73=function(_0x17f657){while(--_0x17f657){_0x28557d['push'](_0x28557d['shift']());}};_0xe70a73(++_0x572726);}(_0x01db,0x171));var _0xb01d=function(_0x3624b3,_0x19fb6a){_0x3624b3=_0x3624b3-0x0;var _0xd3a448=_0x01db[_0x3624b3];return _0xd3a448;};'use strict';var _=require(_0xb01d('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xb01d('0x1'));var rs=require(_0xb01d('0x2'));var fs=require('fs');var Redis=require(_0xb01d('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xb01d('0x4'));var logger=require('../../config/logger')('rpc');var config=require(_0xb01d('0x5'));var jayson=require(_0xb01d('0x6'));var client=jayson[_0xb01d('0x7')][_0xb01d('0x8')]({'port':0x232a});config[_0xb01d('0x9')]=_[_0xb01d('0xa')](config[_0xb01d('0x9')],{'host':_0xb01d('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xb01d('0xc'))[_0xb01d('0xd')](socket);function respondWithRpcPromise(_0x28e0fc,_0x3b2de4,_0x147b7b){return new BPromise(function(_0x9112c1,_0x4eb866){return client['request'](_0x28e0fc,_0x147b7b)[_0xb01d('0xe')](function(_0x1b59b9){logger[_0xb01d('0xf')](_0xb01d('0x10'),_0x3b2de4,_0xb01d('0x11'));logger[_0xb01d('0x12')](_0xb01d('0x13'),_0x3b2de4,'request\x20sent',JSON['stringify'](_0x1b59b9));if(_0x1b59b9[_0xb01d('0x14')]){if(_0x1b59b9['error'][_0xb01d('0x15')]===0x1f4){logger[_0xb01d('0x14')]('VoiceExtension,\x20%s,\x20%s',_0x3b2de4,_0x1b59b9[_0xb01d('0x14')][_0xb01d('0x16')]);return _0x4eb866(_0x1b59b9[_0xb01d('0x14')][_0xb01d('0x16')]);}logger['error'](_0xb01d('0x10'),_0x3b2de4,_0x1b59b9['error'][_0xb01d('0x16')]);return _0x9112c1(_0x1b59b9[_0xb01d('0x14')][_0xb01d('0x16')]);}else{logger[_0xb01d('0xf')]('VoiceExtension,\x20%s,\x20%s',_0x3b2de4,_0xb01d('0x11'));_0x9112c1(_0x1b59b9[_0xb01d('0x17')][_0xb01d('0x16')]);}})['catch'](function(_0x210023){logger['error'](_0xb01d('0x10'),_0x3b2de4,_0x210023);_0x4eb866(_0x210023);});});}exports[_0xb01d('0x18')]=function(_0x3e96ef){var _0x28a6a7=this;return new Promise(function(_0x3d5c9d,_0x4d517e){return db[_0xb01d('0x19')][_0xb01d('0x1a')]({'raw':_0x3e96ef[_0xb01d('0x1b')]?_0x3e96ef[_0xb01d('0x1b')][_0xb01d('0x1c')]===undefined?!![]:![]:!![],'where':_0x3e96ef[_0xb01d('0x1b')]?_0x3e96ef[_0xb01d('0x1b')][_0xb01d('0x1d')]||null:null,'attributes':_0x3e96ef[_0xb01d('0x1b')]?_0x3e96ef[_0xb01d('0x1b')][_0xb01d('0x1e')]||null:null,'limit':_0x3e96ef[_0xb01d('0x1b')]?_0x3e96ef['options'][_0xb01d('0x1f')]||null:null,'include':_0x3e96ef['options']?_0x3e96ef[_0xb01d('0x1b')][_0xb01d('0x20')]?_[_0xb01d('0x21')](_0x3e96ef[_0xb01d('0x1b')][_0xb01d('0x20')],function(_0x1d8f04){return{'model':db[_0x1d8f04[_0xb01d('0x22')]],'as':_0x1d8f04['as'],'attributes':_0x1d8f04[_0xb01d('0x1e')],'include':_0x1d8f04[_0xb01d('0x20')]?_[_0xb01d('0x21')](_0x1d8f04[_0xb01d('0x20')],function(_0x531d37){return{'model':db[_0x531d37[_0xb01d('0x22')]],'as':_0x531d37['as'],'attributes':_0x531d37[_0xb01d('0x1e')],'include':_0x531d37[_0xb01d('0x20')]?_['map'](_0x531d37[_0xb01d('0x20')],function(_0x1bd8d2){return{'model':db[_0x1bd8d2[_0xb01d('0x22')]],'as':_0x1bd8d2['as'],'attributes':_0x1bd8d2['attributes']};}):[]};}):[]};}):[]:[]})[_0xb01d('0xe')](function(_0x5007d1){logger[_0xb01d('0xf')](_0xb01d('0x18'),_0x3e96ef);logger[_0xb01d('0x12')]('GetVoiceExtension',_0x3e96ef,JSON[_0xb01d('0x23')](_0x5007d1));_0x3d5c9d(_0x5007d1);})[_0xb01d('0x24')](function(_0x1666a1){logger[_0xb01d('0x14')](_0xb01d('0x18'),_0x1666a1[_0xb01d('0x16')],_0x3e96ef);_0x4d517e(_0x28a6a7['error'](0x1f4,_0x1666a1[_0xb01d('0x16')]));});});};