Built motion from commit (unavailable).|2.5.2
[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 _0xf012=['catch','GetOpenchannelQueue','OpenchannelQueue','findAll','options','raw','where','attributes','limit','include','map','find','model','ShowOpenchannelQueue','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','redis','localhost','socket.io-emitter','./openchannelQueue.socket','register','request','then','debug','request\x20sent','stringify','error','OpenchannelQueue,\x20%s,\x20%s','message','info','result'];(function(_0x5dedab,_0x32f532){var _0x5d4ab2=function(_0x57cc2a){while(--_0x57cc2a){_0x5dedab['push'](_0x5dedab['shift']());}};_0x5d4ab2(++_0x32f532);}(_0xf012,0x1c6));var _0x2f01=function(_0x3c4d2a,_0x1e5816){_0x3c4d2a=_0x3c4d2a-0x0;var _0x596a0b=_0xf012[_0x3c4d2a];return _0x596a0b;};'use strict';var _=require(_0x2f01('0x0'));var util=require(_0x2f01('0x1'));var moment=require(_0x2f01('0x2'));var BPromise=require(_0x2f01('0x3'));var rs=require(_0x2f01('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2f01('0x5'))['db'];var utils=require(_0x2f01('0x6'));var logger=require(_0x2f01('0x7'))(_0x2f01('0x8'));var config=require(_0x2f01('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x2f01('0xa')]['http']({'port':0x232a});config[_0x2f01('0xb')]=_['defaults'](config['redis'],{'host':_0x2f01('0xc'),'port':0x18eb});var socket=require(_0x2f01('0xd'))(new Redis(config[_0x2f01('0xb')]));require(_0x2f01('0xe'))[_0x2f01('0xf')](socket);function respondWithRpcPromise(_0x451e6a,_0xeb017f,_0x5c3e44){return new BPromise(function(_0x231ce9,_0x183c20){return client[_0x2f01('0x10')](_0x451e6a,_0x5c3e44)[_0x2f01('0x11')](function(_0x2350c2){logger['info']('OpenchannelQueue,\x20%s,\x20%s',_0xeb017f,'request\x20sent');logger[_0x2f01('0x12')]('OpenchannelQueue,\x20%s,\x20%s,\x20%s',_0xeb017f,_0x2f01('0x13'),JSON[_0x2f01('0x14')](_0x2350c2));if(_0x2350c2[_0x2f01('0x15')]){if(_0x2350c2['error']['code']===0x1f4){logger[_0x2f01('0x15')](_0x2f01('0x16'),_0xeb017f,_0x2350c2[_0x2f01('0x15')][_0x2f01('0x17')]);return _0x183c20(_0x2350c2[_0x2f01('0x15')][_0x2f01('0x17')]);}logger[_0x2f01('0x15')](_0x2f01('0x16'),_0xeb017f,_0x2350c2['error'][_0x2f01('0x17')]);return _0x231ce9(_0x2350c2['error']['message']);}else{logger[_0x2f01('0x18')](_0x2f01('0x16'),_0xeb017f,'request\x20sent');_0x231ce9(_0x2350c2[_0x2f01('0x19')][_0x2f01('0x17')]);}})[_0x2f01('0x1a')](function(_0x1365f4){logger[_0x2f01('0x15')](_0x2f01('0x16'),_0xeb017f,_0x1365f4);_0x183c20(_0x1365f4);});});}exports[_0x2f01('0x1b')]=function(_0x22dfe5){var _0x2eb25a=this;return new Promise(function(_0x3f2d6e,_0x40d554){return db[_0x2f01('0x1c')][_0x2f01('0x1d')]({'raw':_0x22dfe5[_0x2f01('0x1e')]?_0x22dfe5[_0x2f01('0x1e')][_0x2f01('0x1f')]===undefined?!![]:![]:!![],'where':_0x22dfe5[_0x2f01('0x1e')]?_0x22dfe5['options'][_0x2f01('0x20')]||null:null,'attributes':_0x22dfe5[_0x2f01('0x1e')]?_0x22dfe5[_0x2f01('0x1e')][_0x2f01('0x21')]||null:null,'limit':_0x22dfe5[_0x2f01('0x1e')]?_0x22dfe5[_0x2f01('0x1e')][_0x2f01('0x22')]||null:null,'include':_0x22dfe5[_0x2f01('0x1e')]?_0x22dfe5['options'][_0x2f01('0x23')]?_[_0x2f01('0x24')](_0x22dfe5[_0x2f01('0x1e')][_0x2f01('0x23')],function(_0x289e8c){return{'model':db[_0x289e8c['model']],'as':_0x289e8c['as'],'attributes':_0x289e8c['attributes'],'include':_0x289e8c[_0x2f01('0x23')]?_[_0x2f01('0x24')](_0x289e8c[_0x2f01('0x23')],function(_0x2bbf0c){return{'model':db[_0x2bbf0c['model']],'as':_0x2bbf0c['as'],'attributes':_0x2bbf0c['attributes'],'include':_0x2bbf0c[_0x2f01('0x23')]?_[_0x2f01('0x24')](_0x2bbf0c[_0x2f01('0x23')],function(_0x54cf06){return{'model':db[_0x54cf06['model']],'as':_0x54cf06['as'],'attributes':_0x54cf06[_0x2f01('0x21')]};}):[]};}):[]};}):[]:[]})[_0x2f01('0x11')](function(_0x1c20cc){logger[_0x2f01('0x18')](_0x2f01('0x1b'),_0x22dfe5);logger['debug'](_0x2f01('0x1b'),_0x22dfe5,JSON[_0x2f01('0x14')](_0x1c20cc));_0x3f2d6e(_0x1c20cc);})[_0x2f01('0x1a')](function(_0x428512){logger[_0x2f01('0x15')](_0x2f01('0x1b'),_0x428512[_0x2f01('0x17')],_0x22dfe5);_0x40d554(_0x2eb25a[_0x2f01('0x15')](0x1f4,_0x428512[_0x2f01('0x17')]));});});};exports['ShowOpenchannelQueue']=function(_0x24ff44){var _0x54d742=this;return new Promise(function(_0x479897,_0x4105c4){return db[_0x2f01('0x1c')][_0x2f01('0x25')]({'raw':_0x24ff44[_0x2f01('0x1e')]?_0x24ff44[_0x2f01('0x1e')][_0x2f01('0x1f')]===undefined?!![]:![]:!![],'where':_0x24ff44[_0x2f01('0x1e')]?_0x24ff44[_0x2f01('0x1e')][_0x2f01('0x20')]||null:null,'attributes':_0x24ff44[_0x2f01('0x1e')]?_0x24ff44[_0x2f01('0x1e')][_0x2f01('0x21')]||null:null,'include':_0x24ff44['options']?_0x24ff44[_0x2f01('0x1e')][_0x2f01('0x23')]?_[_0x2f01('0x24')](_0x24ff44[_0x2f01('0x1e')][_0x2f01('0x23')],function(_0x234414){return{'model':db[_0x234414[_0x2f01('0x26')]],'as':_0x234414['as'],'attributes':_0x234414[_0x2f01('0x21')],'include':_0x234414[_0x2f01('0x23')]?_['map'](_0x234414['include'],function(_0x1a3442){return{'model':db[_0x1a3442['model']],'as':_0x1a3442['as'],'attributes':_0x1a3442[_0x2f01('0x21')],'include':_0x1a3442[_0x2f01('0x23')]?_[_0x2f01('0x24')](_0x1a3442[_0x2f01('0x23')],function(_0x14ee05){return{'model':db[_0x14ee05['model']],'as':_0x14ee05['as'],'attributes':_0x14ee05[_0x2f01('0x21')]};}):[]};}):[]};}):[]:[]})[_0x2f01('0x11')](function(_0xca6d78){logger[_0x2f01('0x18')](_0x2f01('0x27'),_0x24ff44);logger['debug'](_0x2f01('0x27'),_0x24ff44,JSON[_0x2f01('0x14')](_0xca6d78));_0x479897(_0xca6d78);})[_0x2f01('0x1a')](function(_0x6a1656){logger[_0x2f01('0x15')](_0x2f01('0x27'),_0x6a1656[_0x2f01('0x17')],_0x24ff44);_0x4105c4(_0x54d742[_0x2f01('0x15')](0x1f4,_0x6a1656['message']));});});};