cc7a31f767c2c6432397a907d88e96211dba4bc4
[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 _0x0e0f=['model','then','debug','catch','ShowChatQueue','find','where','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./chatQueue.socket','ChatQueue,\x20%s,\x20%s','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','message','info','request\x20sent','result','GetChatQueue','ChatQueue','raw','options','attributes','map','include'];(function(_0x1fa77b,_0x1650d6){var _0x1b7af3=function(_0xb851a1){while(--_0xb851a1){_0x1fa77b['push'](_0x1fa77b['shift']());}};_0x1b7af3(++_0x1650d6);}(_0x0e0f,0xe5));var _0xf0e0=function(_0x280775,_0x366b81){_0x280775=_0x280775-0x0;var _0x36f73b=_0x0e0f[_0x280775];return _0x36f73b;};'use strict';var _=require(_0xf0e0('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xf0e0('0x1'));var rs=require(_0xf0e0('0x2'));var fs=require('fs');var Redis=require(_0xf0e0('0x3'));var db=require(_0xf0e0('0x4'))['db'];var utils=require(_0xf0e0('0x5'));var logger=require('../../config/logger')(_0xf0e0('0x6'));var config=require(_0xf0e0('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xf0e0('0x8')][_0xf0e0('0x9')]({'port':0x232a});config[_0xf0e0('0xa')]=_[_0xf0e0('0xb')](config[_0xf0e0('0xa')],{'host':_0xf0e0('0xc'),'port':0x18eb});var socket=require(_0xf0e0('0xd'))(new Redis(config[_0xf0e0('0xa')]));require(_0xf0e0('0xe'))['register'](socket);function respondWithRpcPromise(_0xed8cc3,_0x47fb29,_0x2936bf){return new BPromise(function(_0x3e890d,_0x28397d){return client['request'](_0xed8cc3,_0x2936bf)['then'](function(_0x533eeb){logger['info'](_0xf0e0('0xf'),_0x47fb29,'request\x20sent');logger['debug'](_0xf0e0('0x10'),_0x47fb29,'request\x20sent',JSON[_0xf0e0('0x11')](_0x533eeb));if(_0x533eeb[_0xf0e0('0x12')]){if(_0x533eeb['error']['code']===0x1f4){logger[_0xf0e0('0x12')]('ChatQueue,\x20%s,\x20%s',_0x47fb29,_0x533eeb[_0xf0e0('0x12')]['message']);return _0x28397d(_0x533eeb[_0xf0e0('0x12')]['message']);}logger[_0xf0e0('0x12')](_0xf0e0('0xf'),_0x47fb29,_0x533eeb['error'][_0xf0e0('0x13')]);return _0x3e890d(_0x533eeb[_0xf0e0('0x12')][_0xf0e0('0x13')]);}else{logger[_0xf0e0('0x14')]('ChatQueue,\x20%s,\x20%s',_0x47fb29,_0xf0e0('0x15'));_0x3e890d(_0x533eeb[_0xf0e0('0x16')]['message']);}})['catch'](function(_0x155a21){logger[_0xf0e0('0x12')]('ChatQueue,\x20%s,\x20%s',_0x47fb29,_0x155a21);_0x28397d(_0x155a21);});});}exports[_0xf0e0('0x17')]=function(_0x5e84f3){var _0x5bdf6c=this;return new Promise(function(_0x5c5dd9,_0x350649){return db[_0xf0e0('0x18')]['findAll']({'raw':_0x5e84f3['options']?_0x5e84f3['options'][_0xf0e0('0x19')]===undefined?!![]:![]:!![],'where':_0x5e84f3['options']?_0x5e84f3['options']['where']||null:null,'attributes':_0x5e84f3['options']?_0x5e84f3[_0xf0e0('0x1a')][_0xf0e0('0x1b')]||null:null,'limit':_0x5e84f3[_0xf0e0('0x1a')]?_0x5e84f3[_0xf0e0('0x1a')]['limit']||null:null,'include':_0x5e84f3[_0xf0e0('0x1a')]?_0x5e84f3[_0xf0e0('0x1a')]['include']?_[_0xf0e0('0x1c')](_0x5e84f3['options'][_0xf0e0('0x1d')],function(_0x364675){return{'model':db[_0x364675['model']],'as':_0x364675['as'],'attributes':_0x364675[_0xf0e0('0x1b')],'include':_0x364675[_0xf0e0('0x1d')]?_['map'](_0x364675[_0xf0e0('0x1d')],function(_0x3eda84){return{'model':db[_0x3eda84[_0xf0e0('0x1e')]],'as':_0x3eda84['as'],'attributes':_0x3eda84[_0xf0e0('0x1b')],'include':_0x3eda84[_0xf0e0('0x1d')]?_[_0xf0e0('0x1c')](_0x3eda84[_0xf0e0('0x1d')],function(_0x3b4a3b){return{'model':db[_0x3b4a3b[_0xf0e0('0x1e')]],'as':_0x3b4a3b['as'],'attributes':_0x3b4a3b[_0xf0e0('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xf0e0('0x1f')](function(_0x5934a9){logger[_0xf0e0('0x14')]('GetChatQueue',_0x5e84f3);logger[_0xf0e0('0x20')]('GetChatQueue',_0x5e84f3,JSON[_0xf0e0('0x11')](_0x5934a9));_0x5c5dd9(_0x5934a9);})[_0xf0e0('0x21')](function(_0x2f6b9d){logger[_0xf0e0('0x12')]('GetChatQueue',_0x2f6b9d[_0xf0e0('0x13')],_0x5e84f3);_0x350649(_0x5bdf6c[_0xf0e0('0x12')](0x1f4,_0x2f6b9d[_0xf0e0('0x13')]));});});};exports[_0xf0e0('0x22')]=function(_0x51f10b){var _0x1c2c16=this;return new Promise(function(_0x37fdec,_0x1929ac){return db[_0xf0e0('0x18')][_0xf0e0('0x23')]({'raw':_0x51f10b['options']?_0x51f10b[_0xf0e0('0x1a')][_0xf0e0('0x19')]===undefined?!![]:![]:!![],'where':_0x51f10b[_0xf0e0('0x1a')]?_0x51f10b[_0xf0e0('0x1a')][_0xf0e0('0x24')]||null:null,'attributes':_0x51f10b['options']?_0x51f10b[_0xf0e0('0x1a')][_0xf0e0('0x1b')]||null:null,'include':_0x51f10b['options']?_0x51f10b[_0xf0e0('0x1a')][_0xf0e0('0x1d')]?_[_0xf0e0('0x1c')](_0x51f10b[_0xf0e0('0x1a')][_0xf0e0('0x1d')],function(_0x1105d7){return{'model':db[_0x1105d7[_0xf0e0('0x1e')]],'as':_0x1105d7['as'],'attributes':_0x1105d7['attributes'],'include':_0x1105d7[_0xf0e0('0x1d')]?_[_0xf0e0('0x1c')](_0x1105d7[_0xf0e0('0x1d')],function(_0x356972){return{'model':db[_0x356972[_0xf0e0('0x1e')]],'as':_0x356972['as'],'attributes':_0x356972[_0xf0e0('0x1b')],'include':_0x356972['include']?_['map'](_0x356972[_0xf0e0('0x1d')],function(_0x5addaf){return{'model':db[_0x5addaf[_0xf0e0('0x1e')]],'as':_0x5addaf['as'],'attributes':_0x5addaf[_0xf0e0('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xf0e0('0x1f')](function(_0x4dec91){logger['info']('ShowChatQueue',_0x51f10b);logger[_0xf0e0('0x20')](_0xf0e0('0x22'),_0x51f10b,JSON[_0xf0e0('0x11')](_0x4dec91));_0x37fdec(_0x4dec91);})[_0xf0e0('0x21')](function(_0x26438d){logger[_0xf0e0('0x12')](_0xf0e0('0x22'),_0x26438d[_0xf0e0('0x13')],_0x51f10b);_0x1929ac(_0x1c2c16[_0xf0e0('0x12')](0x1f4,_0x26438d[_0xf0e0('0x13')]));});});};