Built motion from commit dc14b02d.|2.6.27
[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 _0x51f9=['bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','./chatQueue.socket','register','request','then','info','debug','ChatQueue,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','ChatQueue,\x20%s,\x20%s','message','result','GetChatQueue','ChatQueue','findAll','options','raw','where','limit','include','model','map','attributes','stringify','catch','ShowChatQueue','find','lodash','util'];(function(_0x432682,_0x253044){var _0x463d05=function(_0xa73403){while(--_0xa73403){_0x432682['push'](_0x432682['shift']());}};_0x463d05(++_0x253044);}(_0x51f9,0x132));var _0x951f=function(_0x466247,_0x5d69e3){_0x466247=_0x466247-0x0;var _0x4b352e=_0x51f9[_0x466247];return _0x4b352e;};'use strict';var _=require(_0x951f('0x0'));var util=require(_0x951f('0x1'));var moment=require('moment');var BPromise=require(_0x951f('0x2'));var rs=require(_0x951f('0x3'));var fs=require('fs');var Redis=require(_0x951f('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x951f('0x5'));var logger=require(_0x951f('0x6'))(_0x951f('0x7'));var config=require(_0x951f('0x8'));var jayson=require(_0x951f('0x9'));var client=jayson[_0x951f('0xa')][_0x951f('0xb')]({'port':0x232a});config['redis']=_[_0x951f('0xc')](config[_0x951f('0xd')],{'host':_0x951f('0xe'),'port':0x18eb});var socket=require(_0x951f('0xf'))(new Redis(config[_0x951f('0xd')]));require(_0x951f('0x10'))[_0x951f('0x11')](socket);function respondWithRpcPromise(_0x3b0a01,_0x453eac,_0x110e9a){return new BPromise(function(_0xf8c622,_0x135985){return client[_0x951f('0x12')](_0x3b0a01,_0x110e9a)[_0x951f('0x13')](function(_0x2c582b){logger[_0x951f('0x14')]('ChatQueue,\x20%s,\x20%s',_0x453eac,'request\x20sent');logger[_0x951f('0x15')](_0x951f('0x16'),_0x453eac,_0x951f('0x17'),JSON['stringify'](_0x2c582b));if(_0x2c582b[_0x951f('0x18')]){if(_0x2c582b['error'][_0x951f('0x19')]===0x1f4){logger[_0x951f('0x18')](_0x951f('0x1a'),_0x453eac,_0x2c582b[_0x951f('0x18')][_0x951f('0x1b')]);return _0x135985(_0x2c582b['error'][_0x951f('0x1b')]);}logger[_0x951f('0x18')](_0x951f('0x1a'),_0x453eac,_0x2c582b[_0x951f('0x18')][_0x951f('0x1b')]);return _0xf8c622(_0x2c582b[_0x951f('0x18')][_0x951f('0x1b')]);}else{logger[_0x951f('0x14')](_0x951f('0x1a'),_0x453eac,_0x951f('0x17'));_0xf8c622(_0x2c582b[_0x951f('0x1c')][_0x951f('0x1b')]);}})['catch'](function(_0x3b7994){logger[_0x951f('0x18')](_0x951f('0x1a'),_0x453eac,_0x3b7994);_0x135985(_0x3b7994);});});}exports[_0x951f('0x1d')]=function(_0x36bed2){var _0x4a72fc=this;return new Promise(function(_0xd65ad2,_0x492e75){return db[_0x951f('0x1e')][_0x951f('0x1f')]({'raw':_0x36bed2['options']?_0x36bed2[_0x951f('0x20')][_0x951f('0x21')]===undefined?!![]:![]:!![],'where':_0x36bed2[_0x951f('0x20')]?_0x36bed2['options'][_0x951f('0x22')]||null:null,'attributes':_0x36bed2[_0x951f('0x20')]?_0x36bed2['options']['attributes']||null:null,'limit':_0x36bed2[_0x951f('0x20')]?_0x36bed2[_0x951f('0x20')][_0x951f('0x23')]||null:null,'include':_0x36bed2[_0x951f('0x20')]?_0x36bed2[_0x951f('0x20')]['include']?_['map'](_0x36bed2[_0x951f('0x20')][_0x951f('0x24')],function(_0x5d5698){return{'model':db[_0x5d5698[_0x951f('0x25')]],'as':_0x5d5698['as'],'attributes':_0x5d5698['attributes'],'include':_0x5d5698[_0x951f('0x24')]?_[_0x951f('0x26')](_0x5d5698['include'],function(_0x5f5af3){return{'model':db[_0x5f5af3[_0x951f('0x25')]],'as':_0x5f5af3['as'],'attributes':_0x5f5af3['attributes'],'include':_0x5f5af3['include']?_['map'](_0x5f5af3['include'],function(_0x1d69a1){return{'model':db[_0x1d69a1['model']],'as':_0x1d69a1['as'],'attributes':_0x1d69a1[_0x951f('0x27')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x59b50b){logger[_0x951f('0x14')](_0x951f('0x1d'),_0x36bed2);logger[_0x951f('0x15')]('GetChatQueue',_0x36bed2,JSON[_0x951f('0x28')](_0x59b50b));_0xd65ad2(_0x59b50b);})[_0x951f('0x29')](function(_0x57ed97){logger['error'](_0x951f('0x1d'),_0x57ed97[_0x951f('0x1b')],_0x36bed2);_0x492e75(_0x4a72fc[_0x951f('0x18')](0x1f4,_0x57ed97[_0x951f('0x1b')]));});});};exports[_0x951f('0x2a')]=function(_0x2355bf){var _0x56ad04=this;return new Promise(function(_0x41f82a,_0x154bec){return db[_0x951f('0x1e')][_0x951f('0x2b')]({'raw':_0x2355bf[_0x951f('0x20')]?_0x2355bf[_0x951f('0x20')][_0x951f('0x21')]===undefined?!![]:![]:!![],'where':_0x2355bf[_0x951f('0x20')]?_0x2355bf[_0x951f('0x20')][_0x951f('0x22')]||null:null,'attributes':_0x2355bf['options']?_0x2355bf[_0x951f('0x20')][_0x951f('0x27')]||null:null,'include':_0x2355bf[_0x951f('0x20')]?_0x2355bf[_0x951f('0x20')][_0x951f('0x24')]?_['map'](_0x2355bf[_0x951f('0x20')]['include'],function(_0x1e52b4){return{'model':db[_0x1e52b4[_0x951f('0x25')]],'as':_0x1e52b4['as'],'attributes':_0x1e52b4[_0x951f('0x27')],'include':_0x1e52b4[_0x951f('0x24')]?_[_0x951f('0x26')](_0x1e52b4[_0x951f('0x24')],function(_0x35f1ed){return{'model':db[_0x35f1ed[_0x951f('0x25')]],'as':_0x35f1ed['as'],'attributes':_0x35f1ed[_0x951f('0x27')],'include':_0x35f1ed['include']?_[_0x951f('0x26')](_0x35f1ed[_0x951f('0x24')],function(_0x424143){return{'model':db[_0x424143[_0x951f('0x25')]],'as':_0x424143['as'],'attributes':_0x424143[_0x951f('0x27')]};}):[]};}):[]};}):[]:[]})[_0x951f('0x13')](function(_0x593f0f){logger['info'](_0x951f('0x2a'),_0x2355bf);logger[_0x951f('0x15')]('ShowChatQueue',_0x2355bf,JSON[_0x951f('0x28')](_0x593f0f));_0x41f82a(_0x593f0f);})[_0x951f('0x29')](function(_0x36da2d){logger[_0x951f('0x18')](_0x951f('0x2a'),_0x36da2d[_0x951f('0x1b')],_0x2355bf);_0x154bec(_0x56ad04[_0x951f('0x18')](0x1f4,_0x36da2d['message']));});});};