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 _0x7edb=['info','VoiceExtension,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','GetVoiceExtension','VoiceExtension','findAll','options','raw','where','attributes','map','include','model','then','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','register','request'];(function(_0x8b8564,_0x162976){var _0x360c61=function(_0x164cc9){while(--_0x164cc9){_0x8b8564['push'](_0x8b8564['shift']());}};_0x360c61(++_0x162976);}(_0x7edb,0x158));var _0xb7ed=function(_0x5bda09,_0x49966f){_0x5bda09=_0x5bda09-0x0;var _0x4cbf98=_0x7edb[_0x5bda09];return _0x4cbf98;};'use strict';var _=require('lodash');var util=require(_0xb7ed('0x0'));var moment=require(_0xb7ed('0x1'));var BPromise=require(_0xb7ed('0x2'));var rs=require(_0xb7ed('0x3'));var fs=require('fs');var Redis=require(_0xb7ed('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xb7ed('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0xb7ed('0x6'));var jayson=require(_0xb7ed('0x7'));var client=jayson[_0xb7ed('0x8')][_0xb7ed('0x9')]({'port':0x232a});config[_0xb7ed('0xa')]=_[_0xb7ed('0xb')](config[_0xb7ed('0xa')],{'host':_0xb7ed('0xc'),'port':0x18eb});var socket=require(_0xb7ed('0xd'))(new Redis(config[_0xb7ed('0xa')]));require('./voiceExtension.socket')[_0xb7ed('0xe')](socket);function respondWithRpcPromise(_0x261e4e,_0x183666,_0x6c792e){return new BPromise(function(_0x2d64fc,_0x4104bb){return client[_0xb7ed('0xf')](_0x261e4e,_0x6c792e)['then'](function(_0x38a3f5){logger[_0xb7ed('0x10')](_0xb7ed('0x11'),_0x183666,_0xb7ed('0x12'));logger[_0xb7ed('0x13')]('VoiceExtension,\x20%s,\x20%s,\x20%s',_0x183666,'request\x20sent',JSON[_0xb7ed('0x14')](_0x38a3f5));if(_0x38a3f5['error']){if(_0x38a3f5[_0xb7ed('0x15')][_0xb7ed('0x16')]===0x1f4){logger[_0xb7ed('0x15')](_0xb7ed('0x11'),_0x183666,_0x38a3f5[_0xb7ed('0x15')][_0xb7ed('0x17')]);return _0x4104bb(_0x38a3f5[_0xb7ed('0x15')][_0xb7ed('0x17')]);}logger[_0xb7ed('0x15')](_0xb7ed('0x11'),_0x183666,_0x38a3f5[_0xb7ed('0x15')][_0xb7ed('0x17')]);return _0x2d64fc(_0x38a3f5['error'][_0xb7ed('0x17')]);}else{logger['info'](_0xb7ed('0x11'),_0x183666,_0xb7ed('0x12'));_0x2d64fc(_0x38a3f5['result']['message']);}})[_0xb7ed('0x18')](function(_0x12ff48){logger[_0xb7ed('0x15')]('VoiceExtension,\x20%s,\x20%s',_0x183666,_0x12ff48);_0x4104bb(_0x12ff48);});});}exports[_0xb7ed('0x19')]=function(_0x17f4fa){var _0xa5c636=this;return new Promise(function(_0x6b7e96,_0x483633){return db[_0xb7ed('0x1a')][_0xb7ed('0x1b')]({'raw':_0x17f4fa[_0xb7ed('0x1c')]?_0x17f4fa[_0xb7ed('0x1c')][_0xb7ed('0x1d')]===undefined?!![]:![]:!![],'where':_0x17f4fa[_0xb7ed('0x1c')]?_0x17f4fa[_0xb7ed('0x1c')][_0xb7ed('0x1e')]||null:null,'attributes':_0x17f4fa['options']?_0x17f4fa[_0xb7ed('0x1c')][_0xb7ed('0x1f')]||null:null,'limit':_0x17f4fa['options']?_0x17f4fa['options']['limit']||null:null,'include':_0x17f4fa[_0xb7ed('0x1c')]?_0x17f4fa['options']['include']?_[_0xb7ed('0x20')](_0x17f4fa['options'][_0xb7ed('0x21')],function(_0x52f6c8){return{'model':db[_0x52f6c8[_0xb7ed('0x22')]],'as':_0x52f6c8['as'],'attributes':_0x52f6c8[_0xb7ed('0x1f')],'include':_0x52f6c8[_0xb7ed('0x21')]?_[_0xb7ed('0x20')](_0x52f6c8[_0xb7ed('0x21')],function(_0x59d209){return{'model':db[_0x59d209['model']],'as':_0x59d209['as'],'attributes':_0x59d209[_0xb7ed('0x1f')],'include':_0x59d209[_0xb7ed('0x21')]?_[_0xb7ed('0x20')](_0x59d209[_0xb7ed('0x21')],function(_0x2f726c){return{'model':db[_0x2f726c['model']],'as':_0x2f726c['as'],'attributes':_0x2f726c[_0xb7ed('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xb7ed('0x23')](function(_0x5c8e2e){logger[_0xb7ed('0x10')](_0xb7ed('0x19'),_0x17f4fa);logger[_0xb7ed('0x13')]('GetVoiceExtension',_0x17f4fa,JSON[_0xb7ed('0x14')](_0x5c8e2e));_0x6b7e96(_0x5c8e2e);})[_0xb7ed('0x18')](function(_0x2c4407){logger[_0xb7ed('0x15')]('GetVoiceExtension',_0x2c4407[_0xb7ed('0x17')],_0x17f4fa);_0x483633(_0xa5c636['error'](0x1f4,_0x2c4407[_0xb7ed('0x17')]));});});};