7d572422364a2f92346819e6148e3a5b1ad8a640
[motion2.git] / server / api / openchannelQueue / openchannelQueue.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 _0x399c=['register','then','info','request\x20sent','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','OpenchannelQueue,\x20%s,\x20%s','message','result','catch','GetOpenchannelQueue','OpenchannelQueue','options','raw','where','attributes','limit','include','map','model','ShowOpenchannelQueue','find','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','http','defaults','localhost'];(function(_0x155758,_0x73fd3d){var _0x573c15=function(_0x52f316){while(--_0x52f316){_0x155758['push'](_0x155758['shift']());}};_0x573c15(++_0x73fd3d);}(_0x399c,0xf7));var _0xc399=function(_0x3d2b02,_0x4af5aa){_0x3d2b02=_0x3d2b02-0x0;var _0x45ee5a=_0x399c[_0x3d2b02];return _0x45ee5a;};'use strict';var _=require(_0xc399('0x0'));var util=require(_0xc399('0x1'));var moment=require(_0xc399('0x2'));var BPromise=require('bluebird');var rs=require(_0xc399('0x3'));var fs=require('fs');var Redis=require(_0xc399('0x4'));var db=require(_0xc399('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xc399('0x6'))('rpc');var config=require(_0xc399('0x7'));var jayson=require(_0xc399('0x8'));var client=jayson['client'][_0xc399('0x9')]({'port':0x232a});config['redis']=_[_0xc399('0xa')](config['redis'],{'host':_0xc399('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./openchannelQueue.socket')[_0xc399('0xc')](socket);function respondWithRpcPromise(_0x59f571,_0x598930,_0x1cf123){return new BPromise(function(_0x2358d8,_0x17dbb3){return client['request'](_0x59f571,_0x1cf123)[_0xc399('0xd')](function(_0xf017f3){logger[_0xc399('0xe')]('OpenchannelQueue,\x20%s,\x20%s',_0x598930,_0xc399('0xf'));logger[_0xc399('0x10')](_0xc399('0x11'),_0x598930,'request\x20sent',JSON[_0xc399('0x12')](_0xf017f3));if(_0xf017f3[_0xc399('0x13')]){if(_0xf017f3[_0xc399('0x13')][_0xc399('0x14')]===0x1f4){logger[_0xc399('0x13')](_0xc399('0x15'),_0x598930,_0xf017f3[_0xc399('0x13')][_0xc399('0x16')]);return _0x17dbb3(_0xf017f3[_0xc399('0x13')][_0xc399('0x16')]);}logger[_0xc399('0x13')](_0xc399('0x15'),_0x598930,_0xf017f3[_0xc399('0x13')][_0xc399('0x16')]);return _0x2358d8(_0xf017f3[_0xc399('0x13')][_0xc399('0x16')]);}else{logger[_0xc399('0xe')](_0xc399('0x15'),_0x598930,'request\x20sent');_0x2358d8(_0xf017f3[_0xc399('0x17')][_0xc399('0x16')]);}})[_0xc399('0x18')](function(_0x82cfdc){logger['error']('OpenchannelQueue,\x20%s,\x20%s',_0x598930,_0x82cfdc);_0x17dbb3(_0x82cfdc);});});}exports[_0xc399('0x19')]=function(_0x5bdcc4){var _0x12e170=this;return new Promise(function(_0x597ac6,_0x10be75){return db[_0xc399('0x1a')]['findAll']({'raw':_0x5bdcc4[_0xc399('0x1b')]?_0x5bdcc4[_0xc399('0x1b')][_0xc399('0x1c')]===undefined?!![]:![]:!![],'where':_0x5bdcc4['options']?_0x5bdcc4[_0xc399('0x1b')][_0xc399('0x1d')]||null:null,'attributes':_0x5bdcc4[_0xc399('0x1b')]?_0x5bdcc4[_0xc399('0x1b')][_0xc399('0x1e')]||null:null,'limit':_0x5bdcc4[_0xc399('0x1b')]?_0x5bdcc4[_0xc399('0x1b')][_0xc399('0x1f')]||null:null,'include':_0x5bdcc4[_0xc399('0x1b')]?_0x5bdcc4[_0xc399('0x1b')][_0xc399('0x20')]?_[_0xc399('0x21')](_0x5bdcc4[_0xc399('0x1b')][_0xc399('0x20')],function(_0xa7b9b9){return{'model':db[_0xa7b9b9[_0xc399('0x22')]],'as':_0xa7b9b9['as'],'attributes':_0xa7b9b9[_0xc399('0x1e')],'include':_0xa7b9b9[_0xc399('0x20')]?_['map'](_0xa7b9b9[_0xc399('0x20')],function(_0x125fa3){return{'model':db[_0x125fa3[_0xc399('0x22')]],'as':_0x125fa3['as'],'attributes':_0x125fa3[_0xc399('0x1e')],'include':_0x125fa3[_0xc399('0x20')]?_['map'](_0x125fa3[_0xc399('0x20')],function(_0x491646){return{'model':db[_0x491646[_0xc399('0x22')]],'as':_0x491646['as'],'attributes':_0x491646[_0xc399('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xc399('0xd')](function(_0x38a6cb){logger[_0xc399('0xe')]('GetOpenchannelQueue',_0x5bdcc4);logger[_0xc399('0x10')](_0xc399('0x19'),_0x5bdcc4,JSON[_0xc399('0x12')](_0x38a6cb));_0x597ac6(_0x38a6cb);})[_0xc399('0x18')](function(_0x28e735){logger[_0xc399('0x13')](_0xc399('0x19'),_0x28e735['message'],_0x5bdcc4);_0x10be75(_0x12e170[_0xc399('0x13')](0x1f4,_0x28e735[_0xc399('0x16')]));});});};exports[_0xc399('0x23')]=function(_0x14aa09){var _0x4da251=this;return new Promise(function(_0x1603f3,_0x248d7c){return db[_0xc399('0x1a')][_0xc399('0x24')]({'raw':_0x14aa09['options']?_0x14aa09[_0xc399('0x1b')][_0xc399('0x1c')]===undefined?!![]:![]:!![],'where':_0x14aa09[_0xc399('0x1b')]?_0x14aa09[_0xc399('0x1b')]['where']||null:null,'attributes':_0x14aa09[_0xc399('0x1b')]?_0x14aa09[_0xc399('0x1b')][_0xc399('0x1e')]||null:null,'include':_0x14aa09[_0xc399('0x1b')]?_0x14aa09['options'][_0xc399('0x20')]?_[_0xc399('0x21')](_0x14aa09[_0xc399('0x1b')]['include'],function(_0x12ee88){return{'model':db[_0x12ee88[_0xc399('0x22')]],'as':_0x12ee88['as'],'attributes':_0x12ee88[_0xc399('0x1e')],'include':_0x12ee88['include']?_[_0xc399('0x21')](_0x12ee88[_0xc399('0x20')],function(_0x595442){return{'model':db[_0x595442['model']],'as':_0x595442['as'],'attributes':_0x595442[_0xc399('0x1e')],'include':_0x595442[_0xc399('0x20')]?_[_0xc399('0x21')](_0x595442[_0xc399('0x20')],function(_0x5e8a5f){return{'model':db[_0x5e8a5f[_0xc399('0x22')]],'as':_0x5e8a5f['as'],'attributes':_0x5e8a5f[_0xc399('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xc399('0xd')](function(_0x45d33c){logger[_0xc399('0xe')](_0xc399('0x23'),_0x14aa09);logger['debug']('ShowOpenchannelQueue',_0x14aa09,JSON[_0xc399('0x12')](_0x45d33c));_0x1603f3(_0x45d33c);})['catch'](function(_0xe5b27c){logger['error'](_0xc399('0x23'),_0xe5b27c['message'],_0x14aa09);_0x248d7c(_0x4da251[_0xc399('0x13')](0x1f4,_0xe5b27c[_0xc399('0x16')]));});});};