Built motion from commit 21186556.|2.6.19
[motion2.git] / server / api / chatQueue / chatQueue.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 _0x15f9=['client','http','defaults','redis','localhost','socket.io-emitter','./chatQueue.socket','register','request','then','info','ChatQueue,\x20%s,\x20%s','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s','error','code','message','catch','GetChatQueue','findAll','options','raw','attributes','limit','include','map','stringify','ShowChatQueue','find','where','model','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise'];(function(_0x1e7b16,_0x4607a1){var _0x37fadc=function(_0x1fc9ce){while(--_0x1fc9ce){_0x1e7b16['push'](_0x1e7b16['shift']());}};_0x37fadc(++_0x4607a1);}(_0x15f9,0xf7));var _0x915f=function(_0x44e0c4,_0x5b59f7){_0x44e0c4=_0x44e0c4-0x0;var _0x556148=_0x15f9[_0x44e0c4];return _0x556148;};'use strict';var _=require(_0x915f('0x0'));var util=require(_0x915f('0x1'));var moment=require(_0x915f('0x2'));var BPromise=require(_0x915f('0x3'));var rs=require(_0x915f('0x4'));var fs=require('fs');var Redis=require(_0x915f('0x5'));var db=require(_0x915f('0x6'))['db'];var utils=require(_0x915f('0x7'));var logger=require(_0x915f('0x8'))('rpc');var config=require(_0x915f('0x9'));var jayson=require(_0x915f('0xa'));var client=jayson[_0x915f('0xb')][_0x915f('0xc')]({'port':0x232a});config['redis']=_[_0x915f('0xd')](config[_0x915f('0xe')],{'host':_0x915f('0xf'),'port':0x18eb});var socket=require(_0x915f('0x10'))(new Redis(config['redis']));require(_0x915f('0x11'))[_0x915f('0x12')](socket);function respondWithRpcPromise(_0x57daf8,_0x5da141,_0x3d038f){return new BPromise(function(_0x3746f9,_0x1b125c){return client[_0x915f('0x13')](_0x57daf8,_0x3d038f)[_0x915f('0x14')](function(_0x340a91){logger[_0x915f('0x15')](_0x915f('0x16'),_0x5da141,_0x915f('0x17'));logger[_0x915f('0x18')](_0x915f('0x19'),_0x5da141,_0x915f('0x17'),JSON['stringify'](_0x340a91));if(_0x340a91[_0x915f('0x1a')]){if(_0x340a91[_0x915f('0x1a')][_0x915f('0x1b')]===0x1f4){logger[_0x915f('0x1a')]('ChatQueue,\x20%s,\x20%s',_0x5da141,_0x340a91[_0x915f('0x1a')]['message']);return _0x1b125c(_0x340a91[_0x915f('0x1a')][_0x915f('0x1c')]);}logger['error'](_0x915f('0x16'),_0x5da141,_0x340a91[_0x915f('0x1a')]['message']);return _0x3746f9(_0x340a91[_0x915f('0x1a')][_0x915f('0x1c')]);}else{logger[_0x915f('0x15')]('ChatQueue,\x20%s,\x20%s',_0x5da141,_0x915f('0x17'));_0x3746f9(_0x340a91['result'][_0x915f('0x1c')]);}})[_0x915f('0x1d')](function(_0x4c04c8){logger[_0x915f('0x1a')](_0x915f('0x16'),_0x5da141,_0x4c04c8);_0x1b125c(_0x4c04c8);});});}exports[_0x915f('0x1e')]=function(_0x67e37f){var _0x15d065=this;return new Promise(function(_0x2d65c6,_0x2ba00c){return db['ChatQueue'][_0x915f('0x1f')]({'raw':_0x67e37f[_0x915f('0x20')]?_0x67e37f['options'][_0x915f('0x21')]===undefined?!![]:![]:!![],'where':_0x67e37f[_0x915f('0x20')]?_0x67e37f[_0x915f('0x20')]['where']||null:null,'attributes':_0x67e37f[_0x915f('0x20')]?_0x67e37f[_0x915f('0x20')][_0x915f('0x22')]||null:null,'limit':_0x67e37f[_0x915f('0x20')]?_0x67e37f[_0x915f('0x20')][_0x915f('0x23')]||null:null,'include':_0x67e37f['options']?_0x67e37f[_0x915f('0x20')][_0x915f('0x24')]?_[_0x915f('0x25')](_0x67e37f[_0x915f('0x20')][_0x915f('0x24')],function(_0x1a19e1){return{'model':db[_0x1a19e1['model']],'as':_0x1a19e1['as'],'attributes':_0x1a19e1[_0x915f('0x22')],'include':_0x1a19e1['include']?_['map'](_0x1a19e1[_0x915f('0x24')],function(_0x4ef141){return{'model':db[_0x4ef141['model']],'as':_0x4ef141['as'],'attributes':_0x4ef141[_0x915f('0x22')],'include':_0x4ef141[_0x915f('0x24')]?_[_0x915f('0x25')](_0x4ef141[_0x915f('0x24')],function(_0x5a5ee2){return{'model':db[_0x5a5ee2['model']],'as':_0x5a5ee2['as'],'attributes':_0x5a5ee2[_0x915f('0x22')]};}):[]};}):[]};}):[]:[]})[_0x915f('0x14')](function(_0x258b09){logger[_0x915f('0x15')](_0x915f('0x1e'),_0x67e37f);logger[_0x915f('0x18')]('GetChatQueue',_0x67e37f,JSON[_0x915f('0x26')](_0x258b09));_0x2d65c6(_0x258b09);})['catch'](function(_0x3cc1e0){logger['error'](_0x915f('0x1e'),_0x3cc1e0[_0x915f('0x1c')],_0x67e37f);_0x2ba00c(_0x15d065[_0x915f('0x1a')](0x1f4,_0x3cc1e0[_0x915f('0x1c')]));});});};exports[_0x915f('0x27')]=function(_0x2aac98){var _0x4ca577=this;return new Promise(function(_0x122388,_0x5c0c3){return db['ChatQueue'][_0x915f('0x28')]({'raw':_0x2aac98['options']?_0x2aac98[_0x915f('0x20')][_0x915f('0x21')]===undefined?!![]:![]:!![],'where':_0x2aac98[_0x915f('0x20')]?_0x2aac98[_0x915f('0x20')][_0x915f('0x29')]||null:null,'attributes':_0x2aac98['options']?_0x2aac98[_0x915f('0x20')][_0x915f('0x22')]||null:null,'include':_0x2aac98[_0x915f('0x20')]?_0x2aac98['options'][_0x915f('0x24')]?_[_0x915f('0x25')](_0x2aac98[_0x915f('0x20')][_0x915f('0x24')],function(_0xddfaf1){return{'model':db[_0xddfaf1[_0x915f('0x2a')]],'as':_0xddfaf1['as'],'attributes':_0xddfaf1['attributes'],'include':_0xddfaf1[_0x915f('0x24')]?_['map'](_0xddfaf1[_0x915f('0x24')],function(_0x49e1a8){return{'model':db[_0x49e1a8[_0x915f('0x2a')]],'as':_0x49e1a8['as'],'attributes':_0x49e1a8[_0x915f('0x22')],'include':_0x49e1a8[_0x915f('0x24')]?_['map'](_0x49e1a8[_0x915f('0x24')],function(_0x1f8558){return{'model':db[_0x1f8558[_0x915f('0x2a')]],'as':_0x1f8558['as'],'attributes':_0x1f8558['attributes']};}):[]};}):[]};}):[]:[]})[_0x915f('0x14')](function(_0x2af883){logger['info'](_0x915f('0x27'),_0x2aac98);logger['debug'](_0x915f('0x27'),_0x2aac98,JSON[_0x915f('0x26')](_0x2af883));_0x122388(_0x2af883);})[_0x915f('0x1d')](function(_0x43472f){logger['error'](_0x915f('0x27'),_0x43472f[_0x915f('0x1c')],_0x2aac98);_0x5c0c3(_0x4ca577[_0x915f('0x1a')](0x1f4,_0x43472f[_0x915f('0x1c')]));});});};