7e48d2ee4aa4807ada3e3914140ff10dab39496d
[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 _0x16cc=['../../config/environment','jayson/promise','client','redis','localhost','socket.io-emitter','register','request','then','VoiceExtension,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','catch','GetVoiceExtension','VoiceExtension','findAll','options','raw','where','attributes','include','map','model','info','stringify','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc'];(function(_0x57af69,_0x12df5e){var _0x5ea86c=function(_0x257ad4){while(--_0x257ad4){_0x57af69['push'](_0x57af69['shift']());}};_0x5ea86c(++_0x12df5e);}(_0x16cc,0x120));var _0xc16c=function(_0x150943,_0xd44f4c){_0x150943=_0x150943-0x0;var _0x4db51f=_0x16cc[_0x150943];return _0x4db51f;};'use strict';var _=require('lodash');var util=require(_0xc16c('0x0'));var moment=require(_0xc16c('0x1'));var BPromise=require(_0xc16c('0x2'));var rs=require(_0xc16c('0x3'));var fs=require('fs');var Redis=require(_0xc16c('0x4'));var db=require(_0xc16c('0x5'))['db'];var utils=require(_0xc16c('0x6'));var logger=require('../../config/logger')(_0xc16c('0x7'));var config=require(_0xc16c('0x8'));var jayson=require(_0xc16c('0x9'));var client=jayson[_0xc16c('0xa')]['http']({'port':0x232a});config[_0xc16c('0xb')]=_['defaults'](config[_0xc16c('0xb')],{'host':_0xc16c('0xc'),'port':0x18eb});var socket=require(_0xc16c('0xd'))(new Redis(config[_0xc16c('0xb')]));require('./voiceExtension.socket')[_0xc16c('0xe')](socket);function respondWithRpcPromise(_0x286c40,_0x3f3ff4,_0x462dcf){return new BPromise(function(_0x510afb,_0x2ccba4){return client[_0xc16c('0xf')](_0x286c40,_0x462dcf)[_0xc16c('0x10')](function(_0x4cb366){logger['info'](_0xc16c('0x11'),_0x3f3ff4,_0xc16c('0x12'));logger[_0xc16c('0x13')]('VoiceExtension,\x20%s,\x20%s,\x20%s',_0x3f3ff4,'request\x20sent',JSON['stringify'](_0x4cb366));if(_0x4cb366[_0xc16c('0x14')]){if(_0x4cb366[_0xc16c('0x14')][_0xc16c('0x15')]===0x1f4){logger[_0xc16c('0x14')](_0xc16c('0x11'),_0x3f3ff4,_0x4cb366[_0xc16c('0x14')][_0xc16c('0x16')]);return _0x2ccba4(_0x4cb366[_0xc16c('0x14')][_0xc16c('0x16')]);}logger[_0xc16c('0x14')](_0xc16c('0x11'),_0x3f3ff4,_0x4cb366[_0xc16c('0x14')][_0xc16c('0x16')]);return _0x510afb(_0x4cb366[_0xc16c('0x14')][_0xc16c('0x16')]);}else{logger['info']('VoiceExtension,\x20%s,\x20%s',_0x3f3ff4,_0xc16c('0x12'));_0x510afb(_0x4cb366[_0xc16c('0x17')][_0xc16c('0x16')]);}})[_0xc16c('0x18')](function(_0x432a0a){logger[_0xc16c('0x14')](_0xc16c('0x11'),_0x3f3ff4,_0x432a0a);_0x2ccba4(_0x432a0a);});});}exports[_0xc16c('0x19')]=function(_0x55dc03){var _0x4770d2=this;return new Promise(function(_0x37afc3,_0x121da2){return db[_0xc16c('0x1a')][_0xc16c('0x1b')]({'raw':_0x55dc03[_0xc16c('0x1c')]?_0x55dc03[_0xc16c('0x1c')][_0xc16c('0x1d')]===undefined?!![]:![]:!![],'where':_0x55dc03[_0xc16c('0x1c')]?_0x55dc03[_0xc16c('0x1c')][_0xc16c('0x1e')]||null:null,'attributes':_0x55dc03[_0xc16c('0x1c')]?_0x55dc03[_0xc16c('0x1c')][_0xc16c('0x1f')]||null:null,'limit':_0x55dc03[_0xc16c('0x1c')]?_0x55dc03['options']['limit']||null:null,'include':_0x55dc03[_0xc16c('0x1c')]?_0x55dc03['options'][_0xc16c('0x20')]?_[_0xc16c('0x21')](_0x55dc03['options'][_0xc16c('0x20')],function(_0x4eb194){return{'model':db[_0x4eb194[_0xc16c('0x22')]],'as':_0x4eb194['as'],'attributes':_0x4eb194[_0xc16c('0x1f')],'include':_0x4eb194['include']?_[_0xc16c('0x21')](_0x4eb194[_0xc16c('0x20')],function(_0x323b60){return{'model':db[_0x323b60['model']],'as':_0x323b60['as'],'attributes':_0x323b60[_0xc16c('0x1f')],'include':_0x323b60[_0xc16c('0x20')]?_['map'](_0x323b60[_0xc16c('0x20')],function(_0x1457d4){return{'model':db[_0x1457d4['model']],'as':_0x1457d4['as'],'attributes':_0x1457d4['attributes']};}):[]};}):[]};}):[]:[]})[_0xc16c('0x10')](function(_0x4dd804){logger[_0xc16c('0x23')](_0xc16c('0x19'),_0x55dc03);logger[_0xc16c('0x13')]('GetVoiceExtension',_0x55dc03,JSON[_0xc16c('0x24')](_0x4dd804));_0x37afc3(_0x4dd804);})[_0xc16c('0x18')](function(_0xbe9a46){logger[_0xc16c('0x14')](_0xc16c('0x19'),_0xbe9a46[_0xc16c('0x16')],_0x55dc03);_0x121da2(_0x4770d2[_0xc16c('0x14')](0x1f4,_0xbe9a46[_0xc16c('0x16')]));});});};