Built motion from commit (unavailable).|2.4.18
[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 _0x40f4=['raw','where','limit','map','include','model','attributes','GetOpenchannelQueue','stringify','ShowOpenchannelQueue','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','register','request','then','info','request\x20sent','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','error','message','OpenchannelQueue,\x20%s,\x20%s','catch','OpenchannelQueue','findAll','options'];(function(_0x49ec5f,_0x363c9b){var _0x315ef5=function(_0x380976){while(--_0x380976){_0x49ec5f['push'](_0x49ec5f['shift']());}};_0x315ef5(++_0x363c9b);}(_0x40f4,0x1a4));var _0x440f=function(_0x474e4d,_0x2e4bad){_0x474e4d=_0x474e4d-0x0;var _0x41e52b=_0x40f4[_0x474e4d];return _0x41e52b;};'use strict';var _=require(_0x440f('0x0'));var util=require(_0x440f('0x1'));var moment=require(_0x440f('0x2'));var BPromise=require(_0x440f('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x440f('0x4'));var db=require(_0x440f('0x5'))['db'];var utils=require(_0x440f('0x6'));var logger=require('../../config/logger')(_0x440f('0x7'));var config=require(_0x440f('0x8'));var jayson=require(_0x440f('0x9'));var client=jayson[_0x440f('0xa')][_0x440f('0xb')]({'port':0x232a});config[_0x440f('0xc')]=_[_0x440f('0xd')](config[_0x440f('0xc')],{'host':_0x440f('0xe'),'port':0x18eb});var socket=require(_0x440f('0xf'))(new Redis(config['redis']));require(_0x440f('0x10'))[_0x440f('0x11')](socket);function respondWithRpcPromise(_0x60bbcc,_0x2d9f8b,_0x34968a){return new BPromise(function(_0x1630c7,_0xbc90ba){return client[_0x440f('0x12')](_0x60bbcc,_0x34968a)[_0x440f('0x13')](function(_0x24ef11){logger[_0x440f('0x14')]('OpenchannelQueue,\x20%s,\x20%s',_0x2d9f8b,_0x440f('0x15'));logger[_0x440f('0x16')](_0x440f('0x17'),_0x2d9f8b,_0x440f('0x15'),JSON['stringify'](_0x24ef11));if(_0x24ef11['error']){if(_0x24ef11['error']['code']===0x1f4){logger[_0x440f('0x18')]('OpenchannelQueue,\x20%s,\x20%s',_0x2d9f8b,_0x24ef11[_0x440f('0x18')][_0x440f('0x19')]);return _0xbc90ba(_0x24ef11['error'][_0x440f('0x19')]);}logger[_0x440f('0x18')](_0x440f('0x1a'),_0x2d9f8b,_0x24ef11[_0x440f('0x18')][_0x440f('0x19')]);return _0x1630c7(_0x24ef11[_0x440f('0x18')][_0x440f('0x19')]);}else{logger[_0x440f('0x14')](_0x440f('0x1a'),_0x2d9f8b,_0x440f('0x15'));_0x1630c7(_0x24ef11['result'][_0x440f('0x19')]);}})[_0x440f('0x1b')](function(_0x20bd50){logger['error'](_0x440f('0x1a'),_0x2d9f8b,_0x20bd50);_0xbc90ba(_0x20bd50);});});}exports['GetOpenchannelQueue']=function(_0x52ced4){var _0x15b8e2=this;return new Promise(function(_0x12627b,_0x595a2f){return db[_0x440f('0x1c')][_0x440f('0x1d')]({'raw':_0x52ced4[_0x440f('0x1e')]?_0x52ced4[_0x440f('0x1e')][_0x440f('0x1f')]===undefined?!![]:![]:!![],'where':_0x52ced4[_0x440f('0x1e')]?_0x52ced4[_0x440f('0x1e')][_0x440f('0x20')]||null:null,'attributes':_0x52ced4['options']?_0x52ced4[_0x440f('0x1e')]['attributes']||null:null,'limit':_0x52ced4['options']?_0x52ced4['options'][_0x440f('0x21')]||null:null,'include':_0x52ced4[_0x440f('0x1e')]?_0x52ced4[_0x440f('0x1e')]['include']?_[_0x440f('0x22')](_0x52ced4[_0x440f('0x1e')][_0x440f('0x23')],function(_0x2517d3){return{'model':db[_0x2517d3[_0x440f('0x24')]],'as':_0x2517d3['as'],'attributes':_0x2517d3[_0x440f('0x25')],'include':_0x2517d3[_0x440f('0x23')]?_[_0x440f('0x22')](_0x2517d3[_0x440f('0x23')],function(_0x34e1f3){return{'model':db[_0x34e1f3[_0x440f('0x24')]],'as':_0x34e1f3['as'],'attributes':_0x34e1f3[_0x440f('0x25')],'include':_0x34e1f3[_0x440f('0x23')]?_[_0x440f('0x22')](_0x34e1f3['include'],function(_0x34bd3d){return{'model':db[_0x34bd3d[_0x440f('0x24')]],'as':_0x34bd3d['as'],'attributes':_0x34bd3d[_0x440f('0x25')]};}):[]};}):[]};}):[]:[]})[_0x440f('0x13')](function(_0x30f817){logger['info'](_0x440f('0x26'),_0x52ced4);logger[_0x440f('0x16')](_0x440f('0x26'),_0x52ced4,JSON[_0x440f('0x27')](_0x30f817));_0x12627b(_0x30f817);})['catch'](function(_0x307e15){logger[_0x440f('0x18')](_0x440f('0x26'),_0x307e15['message'],_0x52ced4);_0x595a2f(_0x15b8e2['error'](0x1f4,_0x307e15['message']));});});};exports['ShowOpenchannelQueue']=function(_0x1b9544){var _0x3b7599=this;return new Promise(function(_0x4cc7f5,_0x4bee9a){return db['OpenchannelQueue']['find']({'raw':_0x1b9544[_0x440f('0x1e')]?_0x1b9544[_0x440f('0x1e')][_0x440f('0x1f')]===undefined?!![]:![]:!![],'where':_0x1b9544[_0x440f('0x1e')]?_0x1b9544[_0x440f('0x1e')][_0x440f('0x20')]||null:null,'attributes':_0x1b9544[_0x440f('0x1e')]?_0x1b9544[_0x440f('0x1e')][_0x440f('0x25')]||null:null,'include':_0x1b9544['options']?_0x1b9544[_0x440f('0x1e')][_0x440f('0x23')]?_[_0x440f('0x22')](_0x1b9544[_0x440f('0x1e')][_0x440f('0x23')],function(_0xfa8190){return{'model':db[_0xfa8190[_0x440f('0x24')]],'as':_0xfa8190['as'],'attributes':_0xfa8190[_0x440f('0x25')],'include':_0xfa8190[_0x440f('0x23')]?_[_0x440f('0x22')](_0xfa8190['include'],function(_0x5ab07a){return{'model':db[_0x5ab07a[_0x440f('0x24')]],'as':_0x5ab07a['as'],'attributes':_0x5ab07a[_0x440f('0x25')],'include':_0x5ab07a[_0x440f('0x23')]?_[_0x440f('0x22')](_0x5ab07a[_0x440f('0x23')],function(_0x26abec){return{'model':db[_0x26abec[_0x440f('0x24')]],'as':_0x26abec['as'],'attributes':_0x26abec['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x3ed3c7){logger[_0x440f('0x14')](_0x440f('0x28'),_0x1b9544);logger[_0x440f('0x16')]('ShowOpenchannelQueue',_0x1b9544,JSON[_0x440f('0x27')](_0x3ed3c7));_0x4cc7f5(_0x3ed3c7);})[_0x440f('0x1b')](function(_0x1cebe9){logger['error']('ShowOpenchannelQueue',_0x1cebe9[_0x440f('0x19')],_0x1b9544);_0x4bee9a(_0x3b7599[_0x440f('0x18')](0x1f4,_0x1cebe9[_0x440f('0x19')]));});});};