Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / openchannelQueue / openchannelQueue.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 _0xf264=['stringify','error','code','OpenchannelQueue,\x20%s,\x20%s','message','result','GetOpenchannelQueue','OpenchannelQueue','options','raw','where','attributes','limit','include','map','model','catch','ShowOpenchannelQueue','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','client','http','redis','defaults','socket.io-emitter','./openchannelQueue.socket','then','info','request\x20sent','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s'];(function(_0xdea41a,_0x552987){var _0x15d0d8=function(_0x1e0d0b){while(--_0x1e0d0b){_0xdea41a['push'](_0xdea41a['shift']());}};_0x15d0d8(++_0x552987);}(_0xf264,0xae));var _0x4f26=function(_0x286400,_0x27384d){_0x286400=_0x286400-0x0;var _0x100ee1=_0xf264[_0x286400];return _0x100ee1;};'use strict';var _=require(_0x4f26('0x0'));var util=require(_0x4f26('0x1'));var moment=require(_0x4f26('0x2'));var BPromise=require(_0x4f26('0x3'));var rs=require(_0x4f26('0x4'));var fs=require('fs');var Redis=require(_0x4f26('0x5'));var db=require(_0x4f26('0x6'))['db'];var utils=require(_0x4f26('0x7'));var logger=require('../../config/logger')(_0x4f26('0x8'));var config=require('../../config/environment');var jayson=require(_0x4f26('0x9'));var client=jayson[_0x4f26('0xa')][_0x4f26('0xb')]({'port':0x232a});config[_0x4f26('0xc')]=_[_0x4f26('0xd')](config[_0x4f26('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x4f26('0xe'))(new Redis(config[_0x4f26('0xc')]));require(_0x4f26('0xf'))['register'](socket);function respondWithRpcPromise(_0x1b593a,_0x3d86f0,_0x1741dc){return new BPromise(function(_0x19b3dd,_0x538d9f){return client['request'](_0x1b593a,_0x1741dc)[_0x4f26('0x10')](function(_0xfd9f2b){logger[_0x4f26('0x11')]('OpenchannelQueue,\x20%s,\x20%s',_0x3d86f0,_0x4f26('0x12'));logger[_0x4f26('0x13')](_0x4f26('0x14'),_0x3d86f0,_0x4f26('0x12'),JSON[_0x4f26('0x15')](_0xfd9f2b));if(_0xfd9f2b[_0x4f26('0x16')]){if(_0xfd9f2b[_0x4f26('0x16')][_0x4f26('0x17')]===0x1f4){logger[_0x4f26('0x16')](_0x4f26('0x18'),_0x3d86f0,_0xfd9f2b[_0x4f26('0x16')][_0x4f26('0x19')]);return _0x538d9f(_0xfd9f2b[_0x4f26('0x16')]['message']);}logger[_0x4f26('0x16')](_0x4f26('0x18'),_0x3d86f0,_0xfd9f2b['error'][_0x4f26('0x19')]);return _0x19b3dd(_0xfd9f2b[_0x4f26('0x16')][_0x4f26('0x19')]);}else{logger['info'](_0x4f26('0x18'),_0x3d86f0,_0x4f26('0x12'));_0x19b3dd(_0xfd9f2b[_0x4f26('0x1a')]['message']);}})['catch'](function(_0x374f27){logger['error'](_0x4f26('0x18'),_0x3d86f0,_0x374f27);_0x538d9f(_0x374f27);});});}exports[_0x4f26('0x1b')]=function(_0x1e178a){var _0x4fea03=this;return new Promise(function(_0x38cc78,_0x153626){return db[_0x4f26('0x1c')]['findAll']({'raw':_0x1e178a[_0x4f26('0x1d')]?_0x1e178a[_0x4f26('0x1d')][_0x4f26('0x1e')]===undefined?!![]:![]:!![],'where':_0x1e178a['options']?_0x1e178a['options'][_0x4f26('0x1f')]||null:null,'attributes':_0x1e178a[_0x4f26('0x1d')]?_0x1e178a[_0x4f26('0x1d')][_0x4f26('0x20')]||null:null,'limit':_0x1e178a[_0x4f26('0x1d')]?_0x1e178a['options'][_0x4f26('0x21')]||null:null,'include':_0x1e178a[_0x4f26('0x1d')]?_0x1e178a[_0x4f26('0x1d')][_0x4f26('0x22')]?_[_0x4f26('0x23')](_0x1e178a[_0x4f26('0x1d')][_0x4f26('0x22')],function(_0x4ebf24){return{'model':db[_0x4ebf24[_0x4f26('0x24')]],'as':_0x4ebf24['as'],'attributes':_0x4ebf24[_0x4f26('0x20')],'include':_0x4ebf24[_0x4f26('0x22')]?_[_0x4f26('0x23')](_0x4ebf24[_0x4f26('0x22')],function(_0x443cf2){return{'model':db[_0x443cf2[_0x4f26('0x24')]],'as':_0x443cf2['as'],'attributes':_0x443cf2[_0x4f26('0x20')],'include':_0x443cf2[_0x4f26('0x22')]?_['map'](_0x443cf2['include'],function(_0x4bd207){return{'model':db[_0x4bd207[_0x4f26('0x24')]],'as':_0x4bd207['as'],'attributes':_0x4bd207[_0x4f26('0x20')]};}):[]};}):[]};}):[]:[]})[_0x4f26('0x10')](function(_0x31dcfe){logger[_0x4f26('0x11')]('GetOpenchannelQueue',_0x1e178a);logger['debug'](_0x4f26('0x1b'),_0x1e178a,JSON[_0x4f26('0x15')](_0x31dcfe));_0x38cc78(_0x31dcfe);})[_0x4f26('0x25')](function(_0x220fe5){logger[_0x4f26('0x16')]('GetOpenchannelQueue',_0x220fe5[_0x4f26('0x19')],_0x1e178a);_0x153626(_0x4fea03[_0x4f26('0x16')](0x1f4,_0x220fe5[_0x4f26('0x19')]));});});};exports['ShowOpenchannelQueue']=function(_0x593a0d){var _0x10a652=this;return new Promise(function(_0x3f3adb,_0x21ea84){return db[_0x4f26('0x1c')]['find']({'raw':_0x593a0d[_0x4f26('0x1d')]?_0x593a0d['options'][_0x4f26('0x1e')]===undefined?!![]:![]:!![],'where':_0x593a0d[_0x4f26('0x1d')]?_0x593a0d[_0x4f26('0x1d')]['where']||null:null,'attributes':_0x593a0d['options']?_0x593a0d[_0x4f26('0x1d')]['attributes']||null:null,'include':_0x593a0d['options']?_0x593a0d[_0x4f26('0x1d')][_0x4f26('0x22')]?_[_0x4f26('0x23')](_0x593a0d['options'][_0x4f26('0x22')],function(_0x1436d6){return{'model':db[_0x1436d6[_0x4f26('0x24')]],'as':_0x1436d6['as'],'attributes':_0x1436d6[_0x4f26('0x20')],'include':_0x1436d6[_0x4f26('0x22')]?_['map'](_0x1436d6[_0x4f26('0x22')],function(_0x34ab51){return{'model':db[_0x34ab51[_0x4f26('0x24')]],'as':_0x34ab51['as'],'attributes':_0x34ab51[_0x4f26('0x20')],'include':_0x34ab51[_0x4f26('0x22')]?_[_0x4f26('0x23')](_0x34ab51[_0x4f26('0x22')],function(_0x2d7cd0){return{'model':db[_0x2d7cd0['model']],'as':_0x2d7cd0['as'],'attributes':_0x2d7cd0[_0x4f26('0x20')]};}):[]};}):[]};}):[]:[]})[_0x4f26('0x10')](function(_0x55658d){logger['info'](_0x4f26('0x26'),_0x593a0d);logger[_0x4f26('0x13')](_0x4f26('0x26'),_0x593a0d,JSON[_0x4f26('0x15')](_0x55658d));_0x3f3adb(_0x55658d);})['catch'](function(_0x1aafe4){logger['error'](_0x4f26('0x26'),_0x1aafe4[_0x4f26('0x19')],_0x593a0d);_0x21ea84(_0x10a652[_0x4f26('0x16')](0x1f4,_0x1aafe4[_0x4f26('0x19')]));});});};