Built motion from commit (unavailable).|2.5.14
[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 _0x6996=['findAll','options','where','attributes','include','model','map','then','debug','lodash','util','moment','bluebird','ioredis','../../config/logger','rpc','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','request','info','VoiceExtension,\x20%s,\x20%s','request\x20sent','VoiceExtension,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','GetVoiceExtension','VoiceExtension'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x6996,0x144));var _0x6699=function(_0x44216d,_0x4938a7){_0x44216d=_0x44216d-0x0;var _0xeca523=_0x6996[_0x44216d];return _0xeca523;};'use strict';var _=require(_0x6699('0x0'));var util=require(_0x6699('0x1'));var moment=require(_0x6699('0x2'));var BPromise=require(_0x6699('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x6699('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x6699('0x5'))(_0x6699('0x6'));var config=require('../../config/environment');var jayson=require(_0x6699('0x7'));var client=jayson[_0x6699('0x8')][_0x6699('0x9')]({'port':0x232a});config[_0x6699('0xa')]=_[_0x6699('0xb')](config[_0x6699('0xa')],{'host':_0x6699('0xc'),'port':0x18eb});var socket=require(_0x6699('0xd'))(new Redis(config[_0x6699('0xa')]));require('./voiceExtension.socket')['register'](socket);function respondWithRpcPromise(_0x94d6a4,_0x5c0063,_0x1326aa){return new BPromise(function(_0x38a438,_0x27ced6){return client[_0x6699('0xe')](_0x94d6a4,_0x1326aa)['then'](function(_0x30f3ea){logger[_0x6699('0xf')](_0x6699('0x10'),_0x5c0063,_0x6699('0x11'));logger['debug'](_0x6699('0x12'),_0x5c0063,_0x6699('0x11'),JSON[_0x6699('0x13')](_0x30f3ea));if(_0x30f3ea['error']){if(_0x30f3ea[_0x6699('0x14')][_0x6699('0x15')]===0x1f4){logger[_0x6699('0x14')](_0x6699('0x10'),_0x5c0063,_0x30f3ea[_0x6699('0x14')][_0x6699('0x16')]);return _0x27ced6(_0x30f3ea['error'][_0x6699('0x16')]);}logger['error'](_0x6699('0x10'),_0x5c0063,_0x30f3ea[_0x6699('0x14')][_0x6699('0x16')]);return _0x38a438(_0x30f3ea[_0x6699('0x14')][_0x6699('0x16')]);}else{logger[_0x6699('0xf')]('VoiceExtension,\x20%s,\x20%s',_0x5c0063,_0x6699('0x11'));_0x38a438(_0x30f3ea['result']['message']);}})[_0x6699('0x17')](function(_0x3bd054){logger[_0x6699('0x14')](_0x6699('0x10'),_0x5c0063,_0x3bd054);_0x27ced6(_0x3bd054);});});}exports[_0x6699('0x18')]=function(_0x15c890){var _0x51dd6f=this;return new Promise(function(_0x37a265,_0xc8f48a){return db[_0x6699('0x19')][_0x6699('0x1a')]({'raw':_0x15c890[_0x6699('0x1b')]?_0x15c890['options']['raw']===undefined?!![]:![]:!![],'where':_0x15c890[_0x6699('0x1b')]?_0x15c890[_0x6699('0x1b')][_0x6699('0x1c')]||null:null,'attributes':_0x15c890[_0x6699('0x1b')]?_0x15c890[_0x6699('0x1b')][_0x6699('0x1d')]||null:null,'limit':_0x15c890[_0x6699('0x1b')]?_0x15c890[_0x6699('0x1b')]['limit']||null:null,'include':_0x15c890[_0x6699('0x1b')]?_0x15c890[_0x6699('0x1b')][_0x6699('0x1e')]?_['map'](_0x15c890[_0x6699('0x1b')][_0x6699('0x1e')],function(_0x533051){return{'model':db[_0x533051[_0x6699('0x1f')]],'as':_0x533051['as'],'attributes':_0x533051[_0x6699('0x1d')],'include':_0x533051['include']?_[_0x6699('0x20')](_0x533051[_0x6699('0x1e')],function(_0x3590cb){return{'model':db[_0x3590cb['model']],'as':_0x3590cb['as'],'attributes':_0x3590cb[_0x6699('0x1d')],'include':_0x3590cb[_0x6699('0x1e')]?_['map'](_0x3590cb[_0x6699('0x1e')],function(_0x1e268b){return{'model':db[_0x1e268b[_0x6699('0x1f')]],'as':_0x1e268b['as'],'attributes':_0x1e268b[_0x6699('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x6699('0x21')](function(_0x2084ab){logger[_0x6699('0xf')](_0x6699('0x18'),_0x15c890);logger[_0x6699('0x22')](_0x6699('0x18'),_0x15c890,JSON[_0x6699('0x13')](_0x2084ab));_0x37a265(_0x2084ab);})[_0x6699('0x17')](function(_0x6e566a){logger['error'](_0x6699('0x18'),_0x6e566a[_0x6699('0x16')],_0x15c890);_0xc8f48a(_0x51dd6f[_0x6699('0x14')](0x1f4,_0x6e566a['message']));});});};