Built motion from commit 47436d59.|2.6.7
[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 _0x6200=['ChatQueue,\x20%s,\x20%s','ChatQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','GetChatQueue','ChatQueue','findAll','options','attributes','map','model','include','then','debug','ShowChatQueue','find','raw','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','request','info'];(function(_0x1ffe71,_0x58e4f8){var _0x326d80=function(_0x6845b5){while(--_0x6845b5){_0x1ffe71['push'](_0x1ffe71['shift']());}};_0x326d80(++_0x58e4f8);}(_0x6200,0x192));var _0x0620=function(_0x1069f9,_0x3f5adc){_0x1069f9=_0x1069f9-0x0;var _0x19aced=_0x6200[_0x1069f9];return _0x19aced;};'use strict';var _=require(_0x0620('0x0'));var util=require(_0x0620('0x1'));var moment=require('moment');var BPromise=require(_0x0620('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0620('0x3'));var db=require(_0x0620('0x4'))['db'];var utils=require(_0x0620('0x5'));var logger=require(_0x0620('0x6'))(_0x0620('0x7'));var config=require('../../config/environment');var jayson=require(_0x0620('0x8'));var client=jayson[_0x0620('0x9')]['http']({'port':0x232a});config[_0x0620('0xa')]=_[_0x0620('0xb')](config[_0x0620('0xa')],{'host':_0x0620('0xc'),'port':0x18eb});var socket=require(_0x0620('0xd'))(new Redis(config[_0x0620('0xa')]));require('./chatQueue.socket')['register'](socket);function respondWithRpcPromise(_0x56aa72,_0xb0f8e6,_0x3998a6){return new BPromise(function(_0x339be4,_0x574352){return client[_0x0620('0xe')](_0x56aa72,_0x3998a6)['then'](function(_0x46eb72){logger[_0x0620('0xf')](_0x0620('0x10'),_0xb0f8e6,'request\x20sent');logger['debug'](_0x0620('0x11'),_0xb0f8e6,_0x0620('0x12'),JSON[_0x0620('0x13')](_0x46eb72));if(_0x46eb72[_0x0620('0x14')]){if(_0x46eb72[_0x0620('0x14')][_0x0620('0x15')]===0x1f4){logger[_0x0620('0x14')](_0x0620('0x10'),_0xb0f8e6,_0x46eb72[_0x0620('0x14')][_0x0620('0x16')]);return _0x574352(_0x46eb72[_0x0620('0x14')][_0x0620('0x16')]);}logger[_0x0620('0x14')](_0x0620('0x10'),_0xb0f8e6,_0x46eb72[_0x0620('0x14')][_0x0620('0x16')]);return _0x339be4(_0x46eb72['error'][_0x0620('0x16')]);}else{logger['info']('ChatQueue,\x20%s,\x20%s',_0xb0f8e6,'request\x20sent');_0x339be4(_0x46eb72[_0x0620('0x17')][_0x0620('0x16')]);}})[_0x0620('0x18')](function(_0x13bbe2){logger[_0x0620('0x14')](_0x0620('0x10'),_0xb0f8e6,_0x13bbe2);_0x574352(_0x13bbe2);});});}exports[_0x0620('0x19')]=function(_0x5916bf){var _0x59e197=this;return new Promise(function(_0x28ff49,_0x312b82){return db[_0x0620('0x1a')][_0x0620('0x1b')]({'raw':_0x5916bf['options']?_0x5916bf[_0x0620('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x5916bf['options']?_0x5916bf['options']['where']||null:null,'attributes':_0x5916bf[_0x0620('0x1c')]?_0x5916bf[_0x0620('0x1c')][_0x0620('0x1d')]||null:null,'limit':_0x5916bf['options']?_0x5916bf['options']['limit']||null:null,'include':_0x5916bf[_0x0620('0x1c')]?_0x5916bf['options']['include']?_[_0x0620('0x1e')](_0x5916bf[_0x0620('0x1c')]['include'],function(_0x3bef4d){return{'model':db[_0x3bef4d[_0x0620('0x1f')]],'as':_0x3bef4d['as'],'attributes':_0x3bef4d[_0x0620('0x1d')],'include':_0x3bef4d[_0x0620('0x20')]?_[_0x0620('0x1e')](_0x3bef4d[_0x0620('0x20')],function(_0x4502e7){return{'model':db[_0x4502e7['model']],'as':_0x4502e7['as'],'attributes':_0x4502e7[_0x0620('0x1d')],'include':_0x4502e7[_0x0620('0x20')]?_[_0x0620('0x1e')](_0x4502e7['include'],function(_0x9500ab){return{'model':db[_0x9500ab[_0x0620('0x1f')]],'as':_0x9500ab['as'],'attributes':_0x9500ab[_0x0620('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x0620('0x21')](function(_0x22d756){logger['info']('GetChatQueue',_0x5916bf);logger[_0x0620('0x22')](_0x0620('0x19'),_0x5916bf,JSON[_0x0620('0x13')](_0x22d756));_0x28ff49(_0x22d756);})['catch'](function(_0x1e4d0b){logger['error'](_0x0620('0x19'),_0x1e4d0b[_0x0620('0x16')],_0x5916bf);_0x312b82(_0x59e197[_0x0620('0x14')](0x1f4,_0x1e4d0b[_0x0620('0x16')]));});});};exports[_0x0620('0x23')]=function(_0x4480ff){var _0x595323=this;return new Promise(function(_0x3a97a9,_0x5d1f4b){return db[_0x0620('0x1a')][_0x0620('0x24')]({'raw':_0x4480ff['options']?_0x4480ff[_0x0620('0x1c')][_0x0620('0x25')]===undefined?!![]:![]:!![],'where':_0x4480ff[_0x0620('0x1c')]?_0x4480ff[_0x0620('0x1c')]['where']||null:null,'attributes':_0x4480ff[_0x0620('0x1c')]?_0x4480ff[_0x0620('0x1c')]['attributes']||null:null,'include':_0x4480ff[_0x0620('0x1c')]?_0x4480ff[_0x0620('0x1c')][_0x0620('0x20')]?_[_0x0620('0x1e')](_0x4480ff[_0x0620('0x1c')][_0x0620('0x20')],function(_0x25a72e){return{'model':db[_0x25a72e[_0x0620('0x1f')]],'as':_0x25a72e['as'],'attributes':_0x25a72e[_0x0620('0x1d')],'include':_0x25a72e['include']?_[_0x0620('0x1e')](_0x25a72e[_0x0620('0x20')],function(_0x3be1ed){return{'model':db[_0x3be1ed[_0x0620('0x1f')]],'as':_0x3be1ed['as'],'attributes':_0x3be1ed[_0x0620('0x1d')],'include':_0x3be1ed[_0x0620('0x20')]?_[_0x0620('0x1e')](_0x3be1ed[_0x0620('0x20')],function(_0x304551){return{'model':db[_0x304551[_0x0620('0x1f')]],'as':_0x304551['as'],'attributes':_0x304551[_0x0620('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x0620('0x21')](function(_0x42b09e){logger[_0x0620('0xf')](_0x0620('0x23'),_0x4480ff);logger[_0x0620('0x22')](_0x0620('0x23'),_0x4480ff,JSON[_0x0620('0x13')](_0x42b09e));_0x3a97a9(_0x42b09e);})[_0x0620('0x18')](function(_0x591652){logger[_0x0620('0x14')](_0x0620('0x23'),_0x591652[_0x0620('0x16')],_0x4480ff);_0x5d1f4b(_0x595323[_0x0620('0x14')](0x1f4,_0x591652[_0x0620('0x16')]));});});};