3611a134f8107dc03b23cf900b9782d082718e74
[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 _0xa1f6=['ioredis','jayson/promise','client','http','redis','defaults','localhost','./voiceExtension.socket','register','request','then','info','request\x20sent','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','stringify','error','code','VoiceExtension,\x20%s,\x20%s','message','result','catch','GetVoiceExtension','VoiceExtension','findAll','options','raw','where','attributes','limit','model','include','map','lodash','util','moment','bluebird','randomstring'];(function(_0x37a79c,_0x2b19f0){var _0x561d89=function(_0x19bee3){while(--_0x19bee3){_0x37a79c['push'](_0x37a79c['shift']());}};_0x561d89(++_0x2b19f0);}(_0xa1f6,0x19d));var _0x6a1f=function(_0x3712e2,_0x32d752){_0x3712e2=_0x3712e2-0x0;var _0x1faff4=_0xa1f6[_0x3712e2];return _0x1faff4;};'use strict';var _=require(_0x6a1f('0x0'));var util=require(_0x6a1f('0x1'));var moment=require(_0x6a1f('0x2'));var BPromise=require(_0x6a1f('0x3'));var rs=require(_0x6a1f('0x4'));var fs=require('fs');var Redis=require(_0x6a1f('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x6a1f('0x6'));var client=jayson[_0x6a1f('0x7')][_0x6a1f('0x8')]({'port':0x232a});config[_0x6a1f('0x9')]=_[_0x6a1f('0xa')](config[_0x6a1f('0x9')],{'host':_0x6a1f('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x6a1f('0x9')]));require(_0x6a1f('0xc'))[_0x6a1f('0xd')](socket);function respondWithRpcPromise(_0x287e54,_0x1617b7,_0x5aafd2){return new BPromise(function(_0x30fd4e,_0x17f866){return client[_0x6a1f('0xe')](_0x287e54,_0x5aafd2)[_0x6a1f('0xf')](function(_0x59fc17){logger[_0x6a1f('0x10')]('VoiceExtension,\x20%s,\x20%s',_0x1617b7,_0x6a1f('0x11'));logger[_0x6a1f('0x12')](_0x6a1f('0x13'),_0x1617b7,_0x6a1f('0x11'),JSON[_0x6a1f('0x14')](_0x59fc17));if(_0x59fc17[_0x6a1f('0x15')]){if(_0x59fc17[_0x6a1f('0x15')][_0x6a1f('0x16')]===0x1f4){logger[_0x6a1f('0x15')](_0x6a1f('0x17'),_0x1617b7,_0x59fc17[_0x6a1f('0x15')][_0x6a1f('0x18')]);return _0x17f866(_0x59fc17[_0x6a1f('0x15')][_0x6a1f('0x18')]);}logger[_0x6a1f('0x15')](_0x6a1f('0x17'),_0x1617b7,_0x59fc17[_0x6a1f('0x15')][_0x6a1f('0x18')]);return _0x30fd4e(_0x59fc17[_0x6a1f('0x15')]['message']);}else{logger[_0x6a1f('0x10')](_0x6a1f('0x17'),_0x1617b7,_0x6a1f('0x11'));_0x30fd4e(_0x59fc17[_0x6a1f('0x19')][_0x6a1f('0x18')]);}})[_0x6a1f('0x1a')](function(_0x19562a){logger[_0x6a1f('0x15')]('VoiceExtension,\x20%s,\x20%s',_0x1617b7,_0x19562a);_0x17f866(_0x19562a);});});}exports[_0x6a1f('0x1b')]=function(_0x5100f2){var _0x203f99=this;return new Promise(function(_0x2dfd4e,_0x3c7ed0){return db[_0x6a1f('0x1c')][_0x6a1f('0x1d')]({'raw':_0x5100f2['options']?_0x5100f2[_0x6a1f('0x1e')][_0x6a1f('0x1f')]===undefined?!![]:![]:!![],'where':_0x5100f2[_0x6a1f('0x1e')]?_0x5100f2[_0x6a1f('0x1e')][_0x6a1f('0x20')]||null:null,'attributes':_0x5100f2[_0x6a1f('0x1e')]?_0x5100f2[_0x6a1f('0x1e')][_0x6a1f('0x21')]||null:null,'limit':_0x5100f2['options']?_0x5100f2[_0x6a1f('0x1e')][_0x6a1f('0x22')]||null:null,'include':_0x5100f2['options']?_0x5100f2['options']['include']?_['map'](_0x5100f2[_0x6a1f('0x1e')]['include'],function(_0x5abe40){return{'model':db[_0x5abe40[_0x6a1f('0x23')]],'as':_0x5abe40['as'],'attributes':_0x5abe40[_0x6a1f('0x21')],'include':_0x5abe40[_0x6a1f('0x24')]?_[_0x6a1f('0x25')](_0x5abe40[_0x6a1f('0x24')],function(_0x3bf7f4){return{'model':db[_0x3bf7f4[_0x6a1f('0x23')]],'as':_0x3bf7f4['as'],'attributes':_0x3bf7f4[_0x6a1f('0x21')],'include':_0x3bf7f4['include']?_[_0x6a1f('0x25')](_0x3bf7f4[_0x6a1f('0x24')],function(_0x3f0730){return{'model':db[_0x3f0730['model']],'as':_0x3f0730['as'],'attributes':_0x3f0730[_0x6a1f('0x21')]};}):[]};}):[]};}):[]:[]})[_0x6a1f('0xf')](function(_0x257cee){logger[_0x6a1f('0x10')](_0x6a1f('0x1b'),_0x5100f2);logger[_0x6a1f('0x12')](_0x6a1f('0x1b'),_0x5100f2,JSON['stringify'](_0x257cee));_0x2dfd4e(_0x257cee);})['catch'](function(_0x3aa41a){logger[_0x6a1f('0x15')](_0x6a1f('0x1b'),_0x3aa41a[_0x6a1f('0x18')],_0x5100f2);_0x3c7ed0(_0x203f99[_0x6a1f('0x15')](0x1f4,_0x3aa41a[_0x6a1f('0x18')]));});});};