Built motion from commit (unavailable).|2.6.0
[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 _0x2f0c=['map','model','stringify','ShowChatQueue','find','lodash','util','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','http','defaults','redis','localhost','./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','ChatQueue','findAll','options','raw','where','attributes','limit','include'];(function(_0x56557f,_0xc4df7a){var _0x28ae74=function(_0x140cca){while(--_0x140cca){_0x56557f['push'](_0x56557f['shift']());}};_0x28ae74(++_0xc4df7a);}(_0x2f0c,0x1b2));var _0xc2f0=function(_0x40eec9,_0x817a67){_0x40eec9=_0x40eec9-0x0;var _0xfee890=_0x2f0c[_0x40eec9];return _0xfee890;};'use strict';var _=require(_0xc2f0('0x0'));var util=require(_0xc2f0('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xc2f0('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc2f0('0x3'))['db'];var utils=require(_0xc2f0('0x4'));var logger=require('../../config/logger')(_0xc2f0('0x5'));var config=require(_0xc2f0('0x6'));var jayson=require(_0xc2f0('0x7'));var client=jayson['client'][_0xc2f0('0x8')]({'port':0x232a});config['redis']=_[_0xc2f0('0x9')](config[_0xc2f0('0xa')],{'host':_0xc2f0('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xc2f0('0xa')]));require(_0xc2f0('0xc'))[_0xc2f0('0xd')](socket);function respondWithRpcPromise(_0xc3c26c,_0x6996be,_0x2356af){return new BPromise(function(_0x27920e,_0x14ee86){return client[_0xc2f0('0xe')](_0xc3c26c,_0x2356af)[_0xc2f0('0xf')](function(_0x49231b){logger[_0xc2f0('0x10')](_0xc2f0('0x11'),_0x6996be,_0xc2f0('0x12'));logger[_0xc2f0('0x13')](_0xc2f0('0x14'),_0x6996be,'request\x20sent',JSON['stringify'](_0x49231b));if(_0x49231b[_0xc2f0('0x15')]){if(_0x49231b[_0xc2f0('0x15')][_0xc2f0('0x16')]===0x1f4){logger['error'](_0xc2f0('0x11'),_0x6996be,_0x49231b[_0xc2f0('0x15')]['message']);return _0x14ee86(_0x49231b[_0xc2f0('0x15')][_0xc2f0('0x17')]);}logger[_0xc2f0('0x15')](_0xc2f0('0x11'),_0x6996be,_0x49231b['error'][_0xc2f0('0x17')]);return _0x27920e(_0x49231b[_0xc2f0('0x15')]['message']);}else{logger[_0xc2f0('0x10')](_0xc2f0('0x11'),_0x6996be,_0xc2f0('0x12'));_0x27920e(_0x49231b['result']['message']);}})[_0xc2f0('0x18')](function(_0x1b51e3){logger[_0xc2f0('0x15')]('ChatQueue,\x20%s,\x20%s',_0x6996be,_0x1b51e3);_0x14ee86(_0x1b51e3);});});}exports[_0xc2f0('0x19')]=function(_0x570018){var _0x1d5135=this;return new Promise(function(_0x1b32d1,_0x4b868f){return db[_0xc2f0('0x1a')][_0xc2f0('0x1b')]({'raw':_0x570018[_0xc2f0('0x1c')]?_0x570018['options'][_0xc2f0('0x1d')]===undefined?!![]:![]:!![],'where':_0x570018[_0xc2f0('0x1c')]?_0x570018[_0xc2f0('0x1c')][_0xc2f0('0x1e')]||null:null,'attributes':_0x570018['options']?_0x570018['options'][_0xc2f0('0x1f')]||null:null,'limit':_0x570018[_0xc2f0('0x1c')]?_0x570018['options'][_0xc2f0('0x20')]||null:null,'include':_0x570018[_0xc2f0('0x1c')]?_0x570018[_0xc2f0('0x1c')][_0xc2f0('0x21')]?_[_0xc2f0('0x22')](_0x570018[_0xc2f0('0x1c')]['include'],function(_0x391ef5){return{'model':db[_0x391ef5[_0xc2f0('0x23')]],'as':_0x391ef5['as'],'attributes':_0x391ef5[_0xc2f0('0x1f')],'include':_0x391ef5[_0xc2f0('0x21')]?_['map'](_0x391ef5[_0xc2f0('0x21')],function(_0x302996){return{'model':db[_0x302996[_0xc2f0('0x23')]],'as':_0x302996['as'],'attributes':_0x302996[_0xc2f0('0x1f')],'include':_0x302996['include']?_['map'](_0x302996[_0xc2f0('0x21')],function(_0x245502){return{'model':db[_0x245502['model']],'as':_0x245502['as'],'attributes':_0x245502[_0xc2f0('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xc2f0('0xf')](function(_0x59d0cb){logger[_0xc2f0('0x10')](_0xc2f0('0x19'),_0x570018);logger[_0xc2f0('0x13')](_0xc2f0('0x19'),_0x570018,JSON[_0xc2f0('0x24')](_0x59d0cb));_0x1b32d1(_0x59d0cb);})['catch'](function(_0xee0399){logger[_0xc2f0('0x15')]('GetChatQueue',_0xee0399['message'],_0x570018);_0x4b868f(_0x1d5135[_0xc2f0('0x15')](0x1f4,_0xee0399['message']));});});};exports[_0xc2f0('0x25')]=function(_0x2ccb37){var _0x2ae67a=this;return new Promise(function(_0x13581a,_0x2dfd25){return db['ChatQueue'][_0xc2f0('0x26')]({'raw':_0x2ccb37['options']?_0x2ccb37[_0xc2f0('0x1c')][_0xc2f0('0x1d')]===undefined?!![]:![]:!![],'where':_0x2ccb37[_0xc2f0('0x1c')]?_0x2ccb37[_0xc2f0('0x1c')][_0xc2f0('0x1e')]||null:null,'attributes':_0x2ccb37[_0xc2f0('0x1c')]?_0x2ccb37[_0xc2f0('0x1c')][_0xc2f0('0x1f')]||null:null,'include':_0x2ccb37[_0xc2f0('0x1c')]?_0x2ccb37['options'][_0xc2f0('0x21')]?_[_0xc2f0('0x22')](_0x2ccb37[_0xc2f0('0x1c')]['include'],function(_0x3e67b6){return{'model':db[_0x3e67b6['model']],'as':_0x3e67b6['as'],'attributes':_0x3e67b6[_0xc2f0('0x1f')],'include':_0x3e67b6[_0xc2f0('0x21')]?_[_0xc2f0('0x22')](_0x3e67b6['include'],function(_0x5584b5){return{'model':db[_0x5584b5[_0xc2f0('0x23')]],'as':_0x5584b5['as'],'attributes':_0x5584b5[_0xc2f0('0x1f')],'include':_0x5584b5[_0xc2f0('0x21')]?_[_0xc2f0('0x22')](_0x5584b5['include'],function(_0x46ccd6){return{'model':db[_0x46ccd6[_0xc2f0('0x23')]],'as':_0x46ccd6['as'],'attributes':_0x46ccd6[_0xc2f0('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xc2f0('0xf')](function(_0x3b2dd4){logger[_0xc2f0('0x10')](_0xc2f0('0x25'),_0x2ccb37);logger[_0xc2f0('0x13')](_0xc2f0('0x25'),_0x2ccb37,JSON[_0xc2f0('0x24')](_0x3b2dd4));_0x13581a(_0x3b2dd4);})[_0xc2f0('0x18')](function(_0x17f194){logger[_0xc2f0('0x15')](_0xc2f0('0x25'),_0x17f194[_0xc2f0('0x17')],_0x2ccb37);_0x2dfd25(_0x2ae67a[_0xc2f0('0x15')](0x1f4,_0x17f194['message']));});});};