Built motion from commit da617fac.|2.6.6
[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 _0x8819=['raw','limit','include','model','attributes','map','stringify','catch','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','socket.io-emitter','register','request','then','info','request\x20sent','debug','error','VoiceExtension,\x20%s,\x20%s','message','result','GetVoiceExtension','VoiceExtension','findAll','options'];(function(_0x27f294,_0x2e8998){var _0x17c93a=function(_0x4657f){while(--_0x4657f){_0x27f294['push'](_0x27f294['shift']());}};_0x17c93a(++_0x2e8998);}(_0x8819,0x94));var _0x9881=function(_0x6b9350,_0x4f0163){_0x6b9350=_0x6b9350-0x0;var _0x57d771=_0x8819[_0x6b9350];return _0x57d771;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x9881('0x0'));var BPromise=require(_0x9881('0x1'));var rs=require(_0x9881('0x2'));var fs=require('fs');var Redis=require(_0x9881('0x3'));var db=require(_0x9881('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x9881('0x5'))(_0x9881('0x6'));var config=require(_0x9881('0x7'));var jayson=require(_0x9881('0x8'));var client=jayson[_0x9881('0x9')][_0x9881('0xa')]({'port':0x232a});config['redis']=_[_0x9881('0xb')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x9881('0xc'))(new Redis(config['redis']));require('./voiceExtension.socket')[_0x9881('0xd')](socket);function respondWithRpcPromise(_0x4adf62,_0x2570a3,_0x39122e){return new BPromise(function(_0x1e192a,_0x571947){return client[_0x9881('0xe')](_0x4adf62,_0x39122e)[_0x9881('0xf')](function(_0x2693a6){logger[_0x9881('0x10')]('VoiceExtension,\x20%s,\x20%s',_0x2570a3,_0x9881('0x11'));logger[_0x9881('0x12')]('VoiceExtension,\x20%s,\x20%s,\x20%s',_0x2570a3,_0x9881('0x11'),JSON['stringify'](_0x2693a6));if(_0x2693a6['error']){if(_0x2693a6['error']['code']===0x1f4){logger[_0x9881('0x13')](_0x9881('0x14'),_0x2570a3,_0x2693a6[_0x9881('0x13')][_0x9881('0x15')]);return _0x571947(_0x2693a6[_0x9881('0x13')][_0x9881('0x15')]);}logger['error'](_0x9881('0x14'),_0x2570a3,_0x2693a6[_0x9881('0x13')][_0x9881('0x15')]);return _0x1e192a(_0x2693a6['error']['message']);}else{logger['info'](_0x9881('0x14'),_0x2570a3,'request\x20sent');_0x1e192a(_0x2693a6[_0x9881('0x16')]['message']);}})['catch'](function(_0x1f6e20){logger[_0x9881('0x13')](_0x9881('0x14'),_0x2570a3,_0x1f6e20);_0x571947(_0x1f6e20);});});}exports[_0x9881('0x17')]=function(_0x43f8a2){var _0xe97d44=this;return new Promise(function(_0x3ae21d,_0x1243cc){return db[_0x9881('0x18')][_0x9881('0x19')]({'raw':_0x43f8a2[_0x9881('0x1a')]?_0x43f8a2[_0x9881('0x1a')][_0x9881('0x1b')]===undefined?!![]:![]:!![],'where':_0x43f8a2[_0x9881('0x1a')]?_0x43f8a2[_0x9881('0x1a')]['where']||null:null,'attributes':_0x43f8a2['options']?_0x43f8a2[_0x9881('0x1a')]['attributes']||null:null,'limit':_0x43f8a2['options']?_0x43f8a2[_0x9881('0x1a')][_0x9881('0x1c')]||null:null,'include':_0x43f8a2['options']?_0x43f8a2['options'][_0x9881('0x1d')]?_['map'](_0x43f8a2[_0x9881('0x1a')][_0x9881('0x1d')],function(_0x16eeca){return{'model':db[_0x16eeca[_0x9881('0x1e')]],'as':_0x16eeca['as'],'attributes':_0x16eeca[_0x9881('0x1f')],'include':_0x16eeca[_0x9881('0x1d')]?_[_0x9881('0x20')](_0x16eeca[_0x9881('0x1d')],function(_0xc328b7){return{'model':db[_0xc328b7[_0x9881('0x1e')]],'as':_0xc328b7['as'],'attributes':_0xc328b7[_0x9881('0x1f')],'include':_0xc328b7[_0x9881('0x1d')]?_[_0x9881('0x20')](_0xc328b7['include'],function(_0x31956e){return{'model':db[_0x31956e[_0x9881('0x1e')]],'as':_0x31956e['as'],'attributes':_0x31956e['attributes']};}):[]};}):[]};}):[]:[]})[_0x9881('0xf')](function(_0x3d7120){logger['info'](_0x9881('0x17'),_0x43f8a2);logger[_0x9881('0x12')](_0x9881('0x17'),_0x43f8a2,JSON[_0x9881('0x21')](_0x3d7120));_0x3ae21d(_0x3d7120);})[_0x9881('0x22')](function(_0x383ff0){logger[_0x9881('0x13')](_0x9881('0x17'),_0x383ff0['message'],_0x43f8a2);_0x1243cc(_0xe97d44[_0x9881('0x13')](0x1f4,_0x383ff0[_0x9881('0x15')]));});});};