dabf80982bb615a5712e4f26af6075f9bf692266
[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 _0xafcd=['then','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','redis','localhost','socket.io-emitter','./chatQueue.socket','register','info','ChatQueue,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','catch','GetChatQueue','ChatQueue','findAll','options','where','attributes','map','include','model','stringify','ShowChatQueue'];(function(_0x9bcc0b,_0x120f6c){var _0x195399=function(_0x5be8b9){while(--_0x5be8b9){_0x9bcc0b['push'](_0x9bcc0b['shift']());}};_0x195399(++_0x120f6c);}(_0xafcd,0x157));var _0xdafc=function(_0x292380,_0x2c9565){_0x292380=_0x292380-0x0;var _0x148f5d=_0xafcd[_0x292380];return _0x148f5d;};'use strict';var _=require(_0xdafc('0x0'));var util=require(_0xdafc('0x1'));var moment=require(_0xdafc('0x2'));var BPromise=require(_0xdafc('0x3'));var rs=require(_0xdafc('0x4'));var fs=require('fs');var Redis=require(_0xdafc('0x5'));var db=require(_0xdafc('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0xdafc('0x7'))(_0xdafc('0x8'));var config=require(_0xdafc('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xdafc('0xa')][_0xdafc('0xb')]({'port':0x232a});config[_0xdafc('0xc')]=_['defaults'](config[_0xdafc('0xc')],{'host':_0xdafc('0xd'),'port':0x18eb});var socket=require(_0xdafc('0xe'))(new Redis(config[_0xdafc('0xc')]));require(_0xdafc('0xf'))[_0xdafc('0x10')](socket);function respondWithRpcPromise(_0x3df5fb,_0x312e69,_0x1f87c5){return new BPromise(function(_0x2fdc39,_0x39561b){return client['request'](_0x3df5fb,_0x1f87c5)['then'](function(_0x2a1a6b){logger[_0xdafc('0x11')](_0xdafc('0x12'),_0x312e69,_0xdafc('0x13'));logger[_0xdafc('0x14')]('ChatQueue,\x20%s,\x20%s,\x20%s',_0x312e69,'request\x20sent',JSON['stringify'](_0x2a1a6b));if(_0x2a1a6b[_0xdafc('0x15')]){if(_0x2a1a6b['error'][_0xdafc('0x16')]===0x1f4){logger['error'](_0xdafc('0x12'),_0x312e69,_0x2a1a6b[_0xdafc('0x15')][_0xdafc('0x17')]);return _0x39561b(_0x2a1a6b[_0xdafc('0x15')]['message']);}logger['error'](_0xdafc('0x12'),_0x312e69,_0x2a1a6b[_0xdafc('0x15')][_0xdafc('0x17')]);return _0x2fdc39(_0x2a1a6b['error']['message']);}else{logger[_0xdafc('0x11')](_0xdafc('0x12'),_0x312e69,_0xdafc('0x13'));_0x2fdc39(_0x2a1a6b[_0xdafc('0x18')][_0xdafc('0x17')]);}})[_0xdafc('0x19')](function(_0x1ff505){logger[_0xdafc('0x15')]('ChatQueue,\x20%s,\x20%s',_0x312e69,_0x1ff505);_0x39561b(_0x1ff505);});});}exports[_0xdafc('0x1a')]=function(_0x10258f){var _0x5f4d1d=this;return new Promise(function(_0x239908,_0xb825df){return db[_0xdafc('0x1b')][_0xdafc('0x1c')]({'raw':_0x10258f[_0xdafc('0x1d')]?_0x10258f[_0xdafc('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x10258f['options']?_0x10258f['options'][_0xdafc('0x1e')]||null:null,'attributes':_0x10258f['options']?_0x10258f[_0xdafc('0x1d')][_0xdafc('0x1f')]||null:null,'limit':_0x10258f[_0xdafc('0x1d')]?_0x10258f[_0xdafc('0x1d')]['limit']||null:null,'include':_0x10258f[_0xdafc('0x1d')]?_0x10258f[_0xdafc('0x1d')]['include']?_[_0xdafc('0x20')](_0x10258f[_0xdafc('0x1d')][_0xdafc('0x21')],function(_0x3d3f06){return{'model':db[_0x3d3f06[_0xdafc('0x22')]],'as':_0x3d3f06['as'],'attributes':_0x3d3f06[_0xdafc('0x1f')],'include':_0x3d3f06[_0xdafc('0x21')]?_['map'](_0x3d3f06[_0xdafc('0x21')],function(_0x2d8bb0){return{'model':db[_0x2d8bb0['model']],'as':_0x2d8bb0['as'],'attributes':_0x2d8bb0[_0xdafc('0x1f')],'include':_0x2d8bb0['include']?_['map'](_0x2d8bb0[_0xdafc('0x21')],function(_0x56a820){return{'model':db[_0x56a820[_0xdafc('0x22')]],'as':_0x56a820['as'],'attributes':_0x56a820[_0xdafc('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2752bd){logger['info']('GetChatQueue',_0x10258f);logger['debug'](_0xdafc('0x1a'),_0x10258f,JSON[_0xdafc('0x23')](_0x2752bd));_0x239908(_0x2752bd);})[_0xdafc('0x19')](function(_0x219e1e){logger[_0xdafc('0x15')](_0xdafc('0x1a'),_0x219e1e[_0xdafc('0x17')],_0x10258f);_0xb825df(_0x5f4d1d['error'](0x1f4,_0x219e1e[_0xdafc('0x17')]));});});};exports[_0xdafc('0x24')]=function(_0x51f59f){var _0x5e1f4c=this;return new Promise(function(_0x3d91b5,_0x727050){return db['ChatQueue']['find']({'raw':_0x51f59f[_0xdafc('0x1d')]?_0x51f59f[_0xdafc('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x51f59f['options']?_0x51f59f['options']['where']||null:null,'attributes':_0x51f59f[_0xdafc('0x1d')]?_0x51f59f['options'][_0xdafc('0x1f')]||null:null,'include':_0x51f59f[_0xdafc('0x1d')]?_0x51f59f[_0xdafc('0x1d')][_0xdafc('0x21')]?_['map'](_0x51f59f[_0xdafc('0x1d')][_0xdafc('0x21')],function(_0x25ee4c){return{'model':db[_0x25ee4c[_0xdafc('0x22')]],'as':_0x25ee4c['as'],'attributes':_0x25ee4c[_0xdafc('0x1f')],'include':_0x25ee4c[_0xdafc('0x21')]?_['map'](_0x25ee4c[_0xdafc('0x21')],function(_0x413862){return{'model':db[_0x413862[_0xdafc('0x22')]],'as':_0x413862['as'],'attributes':_0x413862['attributes'],'include':_0x413862[_0xdafc('0x21')]?_['map'](_0x413862[_0xdafc('0x21')],function(_0x4a1591){return{'model':db[_0x4a1591[_0xdafc('0x22')]],'as':_0x4a1591['as'],'attributes':_0x4a1591[_0xdafc('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xdafc('0x25')](function(_0x52ff5b){logger[_0xdafc('0x11')](_0xdafc('0x24'),_0x51f59f);logger[_0xdafc('0x14')]('ShowChatQueue',_0x51f59f,JSON[_0xdafc('0x23')](_0x52ff5b));_0x3d91b5(_0x52ff5b);})['catch'](function(_0x13fc41){logger[_0xdafc('0x15')](_0xdafc('0x24'),_0x13fc41['message'],_0x51f59f);_0x727050(_0x5e1f4c['error'](0x1f4,_0x13fc41[_0xdafc('0x17')]));});});};