d9f2d98a14870bc1d786b92fce59c06915c93c9b
[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 _0x1883=['code','message','VoiceExtension,\x20%s,\x20%s','info','result','catch','GetVoiceExtension','VoiceExtension','findAll','options','where','map','include','model','attributes','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','register','then','request\x20sent','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x1883,0xab));var _0x3188=function(_0xf394d3,_0x4271dc){_0xf394d3=_0xf394d3-0x0;var _0x51462b=_0x1883[_0xf394d3];return _0x51462b;};'use strict';var _=require(_0x3188('0x0'));var util=require(_0x3188('0x1'));var moment=require(_0x3188('0x2'));var BPromise=require(_0x3188('0x3'));var rs=require(_0x3188('0x4'));var fs=require('fs');var Redis=require(_0x3188('0x5'));var db=require(_0x3188('0x6'))['db'];var utils=require(_0x3188('0x7'));var logger=require(_0x3188('0x8'))(_0x3188('0x9'));var config=require(_0x3188('0xa'));var jayson=require(_0x3188('0xb'));var client=jayson[_0x3188('0xc')][_0x3188('0xd')]({'port':0x232a});config[_0x3188('0xe')]=_[_0x3188('0xf')](config[_0x3188('0xe')],{'host':'localhost','port':0x18eb});var socket=require(_0x3188('0x10'))(new Redis(config[_0x3188('0xe')]));require('./voiceExtension.socket')[_0x3188('0x11')](socket);function respondWithRpcPromise(_0x5b7f47,_0xc6040,_0x34fc82){return new BPromise(function(_0x209e31,_0x43b69){return client['request'](_0x5b7f47,_0x34fc82)[_0x3188('0x12')](function(_0x2cdcb2){logger['info']('VoiceExtension,\x20%s,\x20%s',_0xc6040,_0x3188('0x13'));logger[_0x3188('0x14')](_0x3188('0x15'),_0xc6040,_0x3188('0x13'),JSON[_0x3188('0x16')](_0x2cdcb2));if(_0x2cdcb2[_0x3188('0x17')]){if(_0x2cdcb2['error'][_0x3188('0x18')]===0x1f4){logger['error']('VoiceExtension,\x20%s,\x20%s',_0xc6040,_0x2cdcb2[_0x3188('0x17')]['message']);return _0x43b69(_0x2cdcb2['error'][_0x3188('0x19')]);}logger[_0x3188('0x17')](_0x3188('0x1a'),_0xc6040,_0x2cdcb2[_0x3188('0x17')][_0x3188('0x19')]);return _0x209e31(_0x2cdcb2[_0x3188('0x17')]['message']);}else{logger[_0x3188('0x1b')](_0x3188('0x1a'),_0xc6040,_0x3188('0x13'));_0x209e31(_0x2cdcb2[_0x3188('0x1c')][_0x3188('0x19')]);}})[_0x3188('0x1d')](function(_0xac7f48){logger[_0x3188('0x17')]('VoiceExtension,\x20%s,\x20%s',_0xc6040,_0xac7f48);_0x43b69(_0xac7f48);});});}exports[_0x3188('0x1e')]=function(_0x36050a){var _0x5512f4=this;return new Promise(function(_0x518b2f,_0x5d8d62){return db[_0x3188('0x1f')][_0x3188('0x20')]({'raw':_0x36050a[_0x3188('0x21')]?_0x36050a['options']['raw']===undefined?!![]:![]:!![],'where':_0x36050a[_0x3188('0x21')]?_0x36050a[_0x3188('0x21')][_0x3188('0x22')]||null:null,'attributes':_0x36050a[_0x3188('0x21')]?_0x36050a[_0x3188('0x21')]['attributes']||null:null,'limit':_0x36050a[_0x3188('0x21')]?_0x36050a[_0x3188('0x21')]['limit']||null:null,'include':_0x36050a[_0x3188('0x21')]?_0x36050a['options']['include']?_[_0x3188('0x23')](_0x36050a[_0x3188('0x21')][_0x3188('0x24')],function(_0x1aeaba){return{'model':db[_0x1aeaba[_0x3188('0x25')]],'as':_0x1aeaba['as'],'attributes':_0x1aeaba[_0x3188('0x26')],'include':_0x1aeaba[_0x3188('0x24')]?_[_0x3188('0x23')](_0x1aeaba['include'],function(_0x2cc5d9){return{'model':db[_0x2cc5d9[_0x3188('0x25')]],'as':_0x2cc5d9['as'],'attributes':_0x2cc5d9['attributes'],'include':_0x2cc5d9[_0x3188('0x24')]?_[_0x3188('0x23')](_0x2cc5d9[_0x3188('0x24')],function(_0x44db9a){return{'model':db[_0x44db9a[_0x3188('0x25')]],'as':_0x44db9a['as'],'attributes':_0x44db9a[_0x3188('0x26')]};}):[]};}):[]};}):[]:[]})[_0x3188('0x12')](function(_0x472926){logger['info'](_0x3188('0x1e'),_0x36050a);logger['debug'](_0x3188('0x1e'),_0x36050a,JSON['stringify'](_0x472926));_0x518b2f(_0x472926);})[_0x3188('0x1d')](function(_0x80f9a8){logger[_0x3188('0x17')](_0x3188('0x1e'),_0x80f9a8[_0x3188('0x19')],_0x36050a);_0x5d8d62(_0x5512f4[_0x3188('0x17')](0x1f4,_0x80f9a8[_0x3188('0x19')]));});});};