f9997db939d840a2970dd0afbedbc198cc26e47a
[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 _0x6dc0=['localhost','socket.io-emitter','redis','./voiceExtension.socket','register','then','info','VoiceExtension,\x20%s,\x20%s','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','VoiceExtension','findAll','options','limit','include','map','attributes','model','GetVoiceExtension','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','client','http','defaults'];(function(_0x3c6979,_0x54618f){var _0x1a4b83=function(_0x28722d){while(--_0x28722d){_0x3c6979['push'](_0x3c6979['shift']());}};_0x1a4b83(++_0x54618f);}(_0x6dc0,0x18c));var _0x06dc=function(_0x5936ad,_0x199c60){_0x5936ad=_0x5936ad-0x0;var _0x26bed2=_0x6dc0[_0x5936ad];return _0x26bed2;};'use strict';var _=require(_0x06dc('0x0'));var util=require('util');var moment=require(_0x06dc('0x1'));var BPromise=require(_0x06dc('0x2'));var rs=require(_0x06dc('0x3'));var fs=require('fs');var Redis=require(_0x06dc('0x4'));var db=require(_0x06dc('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x06dc('0x6'));var config=require(_0x06dc('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x06dc('0x8')][_0x06dc('0x9')]({'port':0x232a});config['redis']=_[_0x06dc('0xa')](config['redis'],{'host':_0x06dc('0xb'),'port':0x18eb});var socket=require(_0x06dc('0xc'))(new Redis(config[_0x06dc('0xd')]));require(_0x06dc('0xe'))[_0x06dc('0xf')](socket);function respondWithRpcPromise(_0x525edf,_0x185784,_0x48ed87){return new BPromise(function(_0xf637f6,_0x16f5fe){return client['request'](_0x525edf,_0x48ed87)[_0x06dc('0x10')](function(_0x2d0dee){logger[_0x06dc('0x11')](_0x06dc('0x12'),_0x185784,'request\x20sent');logger[_0x06dc('0x13')](_0x06dc('0x14'),_0x185784,_0x06dc('0x15'),JSON[_0x06dc('0x16')](_0x2d0dee));if(_0x2d0dee[_0x06dc('0x17')]){if(_0x2d0dee['error'][_0x06dc('0x18')]===0x1f4){logger[_0x06dc('0x17')](_0x06dc('0x12'),_0x185784,_0x2d0dee[_0x06dc('0x17')][_0x06dc('0x19')]);return _0x16f5fe(_0x2d0dee[_0x06dc('0x17')][_0x06dc('0x19')]);}logger['error'](_0x06dc('0x12'),_0x185784,_0x2d0dee[_0x06dc('0x17')][_0x06dc('0x19')]);return _0xf637f6(_0x2d0dee['error'][_0x06dc('0x19')]);}else{logger[_0x06dc('0x11')](_0x06dc('0x12'),_0x185784,_0x06dc('0x15'));_0xf637f6(_0x2d0dee[_0x06dc('0x1a')][_0x06dc('0x19')]);}})[_0x06dc('0x1b')](function(_0xaf8732){logger['error'](_0x06dc('0x12'),_0x185784,_0xaf8732);_0x16f5fe(_0xaf8732);});});}exports['GetVoiceExtension']=function(_0xe0874b){var _0x5ca842=this;return new Promise(function(_0x41a689,_0x461b34){return db[_0x06dc('0x1c')][_0x06dc('0x1d')]({'raw':_0xe0874b[_0x06dc('0x1e')]?_0xe0874b['options']['raw']===undefined?!![]:![]:!![],'where':_0xe0874b['options']?_0xe0874b['options']['where']||null:null,'attributes':_0xe0874b[_0x06dc('0x1e')]?_0xe0874b[_0x06dc('0x1e')]['attributes']||null:null,'limit':_0xe0874b[_0x06dc('0x1e')]?_0xe0874b[_0x06dc('0x1e')][_0x06dc('0x1f')]||null:null,'include':_0xe0874b[_0x06dc('0x1e')]?_0xe0874b['options'][_0x06dc('0x20')]?_[_0x06dc('0x21')](_0xe0874b[_0x06dc('0x1e')][_0x06dc('0x20')],function(_0x20f761){return{'model':db[_0x20f761['model']],'as':_0x20f761['as'],'attributes':_0x20f761['attributes'],'include':_0x20f761[_0x06dc('0x20')]?_[_0x06dc('0x21')](_0x20f761[_0x06dc('0x20')],function(_0x39d9a4){return{'model':db[_0x39d9a4['model']],'as':_0x39d9a4['as'],'attributes':_0x39d9a4[_0x06dc('0x22')],'include':_0x39d9a4[_0x06dc('0x20')]?_['map'](_0x39d9a4['include'],function(_0x1cf29b){return{'model':db[_0x1cf29b[_0x06dc('0x23')]],'as':_0x1cf29b['as'],'attributes':_0x1cf29b['attributes']};}):[]};}):[]};}):[]:[]})[_0x06dc('0x10')](function(_0x486181){logger[_0x06dc('0x11')](_0x06dc('0x24'),_0xe0874b);logger[_0x06dc('0x13')](_0x06dc('0x24'),_0xe0874b,JSON[_0x06dc('0x16')](_0x486181));_0x41a689(_0x486181);})[_0x06dc('0x1b')](function(_0x2b08e2){logger[_0x06dc('0x17')]('GetVoiceExtension',_0x2b08e2[_0x06dc('0x19')],_0xe0874b);_0x461b34(_0x5ca842[_0x06dc('0x17')](0x1f4,_0x2b08e2[_0x06dc('0x19')]));});});};