Built motion from commit efa66e19.|2.6.22
[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 _0x5e0c=['../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','defaults','localhost','socket.io-emitter','redis','./voiceExtension.socket','request','then','VoiceExtension,\x20%s,\x20%s','request\x20sent','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','error','message','info','result','catch','GetVoiceExtension','options','where','attributes','limit','include','model','stringify','util','moment','bluebird','randomstring','ioredis'];(function(_0x2e65ee,_0x29dad9){var _0x4c712a=function(_0xca593f){while(--_0xca593f){_0x2e65ee['push'](_0x2e65ee['shift']());}};_0x4c712a(++_0x29dad9);}(_0x5e0c,0x19f));var _0xc5e0=function(_0x3217d3,_0xf66fcf){_0x3217d3=_0x3217d3-0x0;var _0x260f43=_0x5e0c[_0x3217d3];return _0x260f43;};'use strict';var _=require('lodash');var util=require(_0xc5e0('0x0'));var moment=require(_0xc5e0('0x1'));var BPromise=require(_0xc5e0('0x2'));var rs=require(_0xc5e0('0x3'));var fs=require('fs');var Redis=require(_0xc5e0('0x4'));var db=require(_0xc5e0('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xc5e0('0x6'))(_0xc5e0('0x7'));var config=require(_0xc5e0('0x8'));var jayson=require(_0xc5e0('0x9'));var client=jayson[_0xc5e0('0xa')]['http']({'port':0x232a});config['redis']=_[_0xc5e0('0xb')](config['redis'],{'host':_0xc5e0('0xc'),'port':0x18eb});var socket=require(_0xc5e0('0xd'))(new Redis(config[_0xc5e0('0xe')]));require(_0xc5e0('0xf'))['register'](socket);function respondWithRpcPromise(_0x2c12b8,_0x558bbd,_0x37627e){return new BPromise(function(_0x33d821,_0x1d3618){return client[_0xc5e0('0x10')](_0x2c12b8,_0x37627e)[_0xc5e0('0x11')](function(_0x44980b){logger['info'](_0xc5e0('0x12'),_0x558bbd,_0xc5e0('0x13'));logger[_0xc5e0('0x14')](_0xc5e0('0x15'),_0x558bbd,_0xc5e0('0x13'),JSON['stringify'](_0x44980b));if(_0x44980b[_0xc5e0('0x16')]){if(_0x44980b[_0xc5e0('0x16')]['code']===0x1f4){logger['error'](_0xc5e0('0x12'),_0x558bbd,_0x44980b['error']['message']);return _0x1d3618(_0x44980b[_0xc5e0('0x16')][_0xc5e0('0x17')]);}logger[_0xc5e0('0x16')](_0xc5e0('0x12'),_0x558bbd,_0x44980b[_0xc5e0('0x16')][_0xc5e0('0x17')]);return _0x33d821(_0x44980b[_0xc5e0('0x16')][_0xc5e0('0x17')]);}else{logger[_0xc5e0('0x18')](_0xc5e0('0x12'),_0x558bbd,_0xc5e0('0x13'));_0x33d821(_0x44980b[_0xc5e0('0x19')][_0xc5e0('0x17')]);}})[_0xc5e0('0x1a')](function(_0x5c534d){logger['error'](_0xc5e0('0x12'),_0x558bbd,_0x5c534d);_0x1d3618(_0x5c534d);});});}exports[_0xc5e0('0x1b')]=function(_0x3d7981){var _0x2dba3d=this;return new Promise(function(_0x4214b0,_0x106819){return db['VoiceExtension']['findAll']({'raw':_0x3d7981['options']?_0x3d7981[_0xc5e0('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x3d7981[_0xc5e0('0x1c')]?_0x3d7981[_0xc5e0('0x1c')][_0xc5e0('0x1d')]||null:null,'attributes':_0x3d7981[_0xc5e0('0x1c')]?_0x3d7981[_0xc5e0('0x1c')][_0xc5e0('0x1e')]||null:null,'limit':_0x3d7981[_0xc5e0('0x1c')]?_0x3d7981['options'][_0xc5e0('0x1f')]||null:null,'include':_0x3d7981['options']?_0x3d7981[_0xc5e0('0x1c')][_0xc5e0('0x20')]?_['map'](_0x3d7981['options']['include'],function(_0x30f734){return{'model':db[_0x30f734['model']],'as':_0x30f734['as'],'attributes':_0x30f734[_0xc5e0('0x1e')],'include':_0x30f734[_0xc5e0('0x20')]?_['map'](_0x30f734[_0xc5e0('0x20')],function(_0x331e07){return{'model':db[_0x331e07[_0xc5e0('0x21')]],'as':_0x331e07['as'],'attributes':_0x331e07[_0xc5e0('0x1e')],'include':_0x331e07['include']?_['map'](_0x331e07['include'],function(_0x4b30d9){return{'model':db[_0x4b30d9[_0xc5e0('0x21')]],'as':_0x4b30d9['as'],'attributes':_0x4b30d9['attributes']};}):[]};}):[]};}):[]:[]})[_0xc5e0('0x11')](function(_0x19f77a){logger[_0xc5e0('0x18')](_0xc5e0('0x1b'),_0x3d7981);logger['debug'](_0xc5e0('0x1b'),_0x3d7981,JSON[_0xc5e0('0x22')](_0x19f77a));_0x4214b0(_0x19f77a);})['catch'](function(_0x40b717){logger[_0xc5e0('0x16')](_0xc5e0('0x1b'),_0x40b717[_0xc5e0('0x17')],_0x3d7981);_0x106819(_0x2dba3d[_0xc5e0('0x16')](0x1f4,_0x40b717[_0xc5e0('0x17')]));});});};