Built motion from commit ac06311e.|2.6.28
[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 _0xbdb9=['debug','VoiceExtension,\x20%s,\x20%s,\x20%s','error','code','message','result','GetVoiceExtension','VoiceExtension','findAll','options','raw','where','limit','include','map','attributes','model','then','stringify','catch','lodash','util','moment','bluebird','randomstring','../../mysqldb','jayson/promise','http','defaults','redis','localhost','socket.io-emitter','./voiceExtension.socket','register','request','info','VoiceExtension,\x20%s,\x20%s','request\x20sent'];(function(_0x4d31de,_0x4e403f){var _0x515423=function(_0x57c4dc){while(--_0x57c4dc){_0x4d31de['push'](_0x4d31de['shift']());}};_0x515423(++_0x4e403f);}(_0xbdb9,0xac));var _0x9bdb=function(_0x213aa7,_0x26e5b8){_0x213aa7=_0x213aa7-0x0;var _0x2b60b7=_0xbdb9[_0x213aa7];return _0x2b60b7;};'use strict';var _=require(_0x9bdb('0x0'));var util=require(_0x9bdb('0x1'));var moment=require(_0x9bdb('0x2'));var BPromise=require(_0x9bdb('0x3'));var rs=require(_0x9bdb('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x9bdb('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x9bdb('0x6'));var client=jayson['client'][_0x9bdb('0x7')]({'port':0x232a});config['redis']=_[_0x9bdb('0x8')](config[_0x9bdb('0x9')],{'host':_0x9bdb('0xa'),'port':0x18eb});var socket=require(_0x9bdb('0xb'))(new Redis(config[_0x9bdb('0x9')]));require(_0x9bdb('0xc'))[_0x9bdb('0xd')](socket);function respondWithRpcPromise(_0x58812d,_0x118bb1,_0x355bad){return new BPromise(function(_0x274dee,_0x35a5b9){return client[_0x9bdb('0xe')](_0x58812d,_0x355bad)['then'](function(_0x5af5d6){logger[_0x9bdb('0xf')](_0x9bdb('0x10'),_0x118bb1,_0x9bdb('0x11'));logger[_0x9bdb('0x12')](_0x9bdb('0x13'),_0x118bb1,_0x9bdb('0x11'),JSON['stringify'](_0x5af5d6));if(_0x5af5d6[_0x9bdb('0x14')]){if(_0x5af5d6[_0x9bdb('0x14')][_0x9bdb('0x15')]===0x1f4){logger[_0x9bdb('0x14')](_0x9bdb('0x10'),_0x118bb1,_0x5af5d6['error'][_0x9bdb('0x16')]);return _0x35a5b9(_0x5af5d6[_0x9bdb('0x14')][_0x9bdb('0x16')]);}logger['error'](_0x9bdb('0x10'),_0x118bb1,_0x5af5d6[_0x9bdb('0x14')][_0x9bdb('0x16')]);return _0x274dee(_0x5af5d6[_0x9bdb('0x14')][_0x9bdb('0x16')]);}else{logger[_0x9bdb('0xf')](_0x9bdb('0x10'),_0x118bb1,_0x9bdb('0x11'));_0x274dee(_0x5af5d6[_0x9bdb('0x17')][_0x9bdb('0x16')]);}})['catch'](function(_0x37837d){logger[_0x9bdb('0x14')]('VoiceExtension,\x20%s,\x20%s',_0x118bb1,_0x37837d);_0x35a5b9(_0x37837d);});});}exports[_0x9bdb('0x18')]=function(_0x16a953){var _0x2fb1f3=this;return new Promise(function(_0x582a46,_0xdaab91){return db[_0x9bdb('0x19')][_0x9bdb('0x1a')]({'raw':_0x16a953['options']?_0x16a953[_0x9bdb('0x1b')][_0x9bdb('0x1c')]===undefined?!![]:![]:!![],'where':_0x16a953[_0x9bdb('0x1b')]?_0x16a953[_0x9bdb('0x1b')][_0x9bdb('0x1d')]||null:null,'attributes':_0x16a953[_0x9bdb('0x1b')]?_0x16a953['options']['attributes']||null:null,'limit':_0x16a953[_0x9bdb('0x1b')]?_0x16a953[_0x9bdb('0x1b')][_0x9bdb('0x1e')]||null:null,'include':_0x16a953['options']?_0x16a953[_0x9bdb('0x1b')][_0x9bdb('0x1f')]?_[_0x9bdb('0x20')](_0x16a953[_0x9bdb('0x1b')]['include'],function(_0x37a02a){return{'model':db[_0x37a02a['model']],'as':_0x37a02a['as'],'attributes':_0x37a02a[_0x9bdb('0x21')],'include':_0x37a02a[_0x9bdb('0x1f')]?_[_0x9bdb('0x20')](_0x37a02a['include'],function(_0x158604){return{'model':db[_0x158604[_0x9bdb('0x22')]],'as':_0x158604['as'],'attributes':_0x158604[_0x9bdb('0x21')],'include':_0x158604[_0x9bdb('0x1f')]?_[_0x9bdb('0x20')](_0x158604[_0x9bdb('0x1f')],function(_0x426390){return{'model':db[_0x426390[_0x9bdb('0x22')]],'as':_0x426390['as'],'attributes':_0x426390[_0x9bdb('0x21')]};}):[]};}):[]};}):[]:[]})[_0x9bdb('0x23')](function(_0x54ed65){logger[_0x9bdb('0xf')](_0x9bdb('0x18'),_0x16a953);logger[_0x9bdb('0x12')](_0x9bdb('0x18'),_0x16a953,JSON[_0x9bdb('0x24')](_0x54ed65));_0x582a46(_0x54ed65);})[_0x9bdb('0x25')](function(_0x106160){logger['error'](_0x9bdb('0x18'),_0x106160['message'],_0x16a953);_0xdaab91(_0x2fb1f3[_0x9bdb('0x14')](0x1f4,_0x106160[_0x9bdb('0x16')]));});});};