Built motion from commit 598073ad.|2.5.44
[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 _0x6003=['../../config/logger','../../config/environment','jayson/promise','http','redis','socket.io-emitter','./voiceExtension.socket','register','request','then','info','VoiceExtension,\x20%s,\x20%s','request\x20sent','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','GetVoiceExtension','findAll','options','raw','where','attributes','limit','include','map','model','lodash','util','moment','bluebird','../../mysqldb','../../config/utils'];(function(_0x38cb39,_0x252cab){var _0x1da539=function(_0x3cff6a){while(--_0x3cff6a){_0x38cb39['push'](_0x38cb39['shift']());}};_0x1da539(++_0x252cab);}(_0x6003,0xae));var _0x3600=function(_0x1149f3,_0x24d796){_0x1149f3=_0x1149f3-0x0;var _0x277503=_0x6003[_0x1149f3];return _0x277503;};'use strict';var _=require(_0x3600('0x0'));var util=require(_0x3600('0x1'));var moment=require(_0x3600('0x2'));var BPromise=require(_0x3600('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x3600('0x4'))['db'];var utils=require(_0x3600('0x5'));var logger=require(_0x3600('0x6'))('rpc');var config=require(_0x3600('0x7'));var jayson=require(_0x3600('0x8'));var client=jayson['client'][_0x3600('0x9')]({'port':0x232a});config['redis']=_['defaults'](config[_0x3600('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0x3600('0xb'))(new Redis(config['redis']));require(_0x3600('0xc'))[_0x3600('0xd')](socket);function respondWithRpcPromise(_0xb42a2f,_0x18f52a,_0x5b30c1){return new BPromise(function(_0x1ae5d2,_0x2c4b45){return client[_0x3600('0xe')](_0xb42a2f,_0x5b30c1)[_0x3600('0xf')](function(_0x43b701){logger[_0x3600('0x10')](_0x3600('0x11'),_0x18f52a,_0x3600('0x12'));logger[_0x3600('0x13')](_0x3600('0x14'),_0x18f52a,_0x3600('0x12'),JSON[_0x3600('0x15')](_0x43b701));if(_0x43b701['error']){if(_0x43b701[_0x3600('0x16')]['code']===0x1f4){logger['error'](_0x3600('0x11'),_0x18f52a,_0x43b701[_0x3600('0x16')][_0x3600('0x17')]);return _0x2c4b45(_0x43b701['error'][_0x3600('0x17')]);}logger['error'](_0x3600('0x11'),_0x18f52a,_0x43b701['error'][_0x3600('0x17')]);return _0x1ae5d2(_0x43b701[_0x3600('0x16')][_0x3600('0x17')]);}else{logger['info']('VoiceExtension,\x20%s,\x20%s',_0x18f52a,_0x3600('0x12'));_0x1ae5d2(_0x43b701[_0x3600('0x18')][_0x3600('0x17')]);}})[_0x3600('0x19')](function(_0x4bfb07){logger[_0x3600('0x16')]('VoiceExtension,\x20%s,\x20%s',_0x18f52a,_0x4bfb07);_0x2c4b45(_0x4bfb07);});});}exports[_0x3600('0x1a')]=function(_0x3d2830){var _0xaaa5a9=this;return new Promise(function(_0x4827c4,_0x8390c1){return db['VoiceExtension'][_0x3600('0x1b')]({'raw':_0x3d2830[_0x3600('0x1c')]?_0x3d2830[_0x3600('0x1c')][_0x3600('0x1d')]===undefined?!![]:![]:!![],'where':_0x3d2830[_0x3600('0x1c')]?_0x3d2830['options'][_0x3600('0x1e')]||null:null,'attributes':_0x3d2830[_0x3600('0x1c')]?_0x3d2830[_0x3600('0x1c')][_0x3600('0x1f')]||null:null,'limit':_0x3d2830[_0x3600('0x1c')]?_0x3d2830[_0x3600('0x1c')][_0x3600('0x20')]||null:null,'include':_0x3d2830[_0x3600('0x1c')]?_0x3d2830[_0x3600('0x1c')][_0x3600('0x21')]?_[_0x3600('0x22')](_0x3d2830['options'][_0x3600('0x21')],function(_0x50a222){return{'model':db[_0x50a222[_0x3600('0x23')]],'as':_0x50a222['as'],'attributes':_0x50a222['attributes'],'include':_0x50a222[_0x3600('0x21')]?_[_0x3600('0x22')](_0x50a222[_0x3600('0x21')],function(_0x32bfef){return{'model':db[_0x32bfef[_0x3600('0x23')]],'as':_0x32bfef['as'],'attributes':_0x32bfef[_0x3600('0x1f')],'include':_0x32bfef['include']?_[_0x3600('0x22')](_0x32bfef[_0x3600('0x21')],function(_0x5580b9){return{'model':db[_0x5580b9[_0x3600('0x23')]],'as':_0x5580b9['as'],'attributes':_0x5580b9[_0x3600('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x3600('0xf')](function(_0x861d1){logger[_0x3600('0x10')](_0x3600('0x1a'),_0x3d2830);logger[_0x3600('0x13')](_0x3600('0x1a'),_0x3d2830,JSON['stringify'](_0x861d1));_0x4827c4(_0x861d1);})['catch'](function(_0x386e47){logger['error'](_0x3600('0x1a'),_0x386e47[_0x3600('0x17')],_0x3d2830);_0x8390c1(_0xaaa5a9[_0x3600('0x16')](0x1f4,_0x386e47['message']));});});};