Built motion from commit (unavailable).|2.5.10
[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 _0xdd8f=['jayson/promise','client','defaults','localhost','socket.io-emitter','redis','request','then','info','OpenchannelQueue,\x20%s,\x20%s','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','GetOpenchannelQueue','OpenchannelQueue','options','raw','limit','include','map','model','attributes','ShowOpenchannelQueue','find','where','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment'];(function(_0xd33801,_0x2c8c0f){var _0x420bb9=function(_0x55fad2){while(--_0x55fad2){_0xd33801['push'](_0xd33801['shift']());}};_0x420bb9(++_0x2c8c0f);}(_0xdd8f,0x1f2));var _0xfdd8=function(_0x16990e,_0x260a75){_0x16990e=_0x16990e-0x0;var _0x3df36e=_0xdd8f[_0x16990e];return _0x3df36e;};'use strict';var _=require(_0xfdd8('0x0'));var util=require('util');var moment=require(_0xfdd8('0x1'));var BPromise=require(_0xfdd8('0x2'));var rs=require(_0xfdd8('0x3'));var fs=require('fs');var Redis=require(_0xfdd8('0x4'));var db=require(_0xfdd8('0x5'))['db'];var utils=require(_0xfdd8('0x6'));var logger=require(_0xfdd8('0x7'))('rpc');var config=require(_0xfdd8('0x8'));var jayson=require(_0xfdd8('0x9'));var client=jayson[_0xfdd8('0xa')]['http']({'port':0x232a});config['redis']=_[_0xfdd8('0xb')](config['redis'],{'host':_0xfdd8('0xc'),'port':0x18eb});var socket=require(_0xfdd8('0xd'))(new Redis(config[_0xfdd8('0xe')]));require('./openchannelQueue.socket')['register'](socket);function respondWithRpcPromise(_0x1fcf1c,_0x29d432,_0x263529){return new BPromise(function(_0x175f4a,_0x505c3f){return client[_0xfdd8('0xf')](_0x1fcf1c,_0x263529)[_0xfdd8('0x10')](function(_0x2683ec){logger[_0xfdd8('0x11')](_0xfdd8('0x12'),_0x29d432,'request\x20sent');logger[_0xfdd8('0x13')](_0xfdd8('0x14'),_0x29d432,_0xfdd8('0x15'),JSON[_0xfdd8('0x16')](_0x2683ec));if(_0x2683ec[_0xfdd8('0x17')]){if(_0x2683ec[_0xfdd8('0x17')]['code']===0x1f4){logger['error']('OpenchannelQueue,\x20%s,\x20%s',_0x29d432,_0x2683ec['error']['message']);return _0x505c3f(_0x2683ec[_0xfdd8('0x17')]['message']);}logger[_0xfdd8('0x17')](_0xfdd8('0x12'),_0x29d432,_0x2683ec['error'][_0xfdd8('0x18')]);return _0x175f4a(_0x2683ec[_0xfdd8('0x17')][_0xfdd8('0x18')]);}else{logger[_0xfdd8('0x11')](_0xfdd8('0x12'),_0x29d432,'request\x20sent');_0x175f4a(_0x2683ec[_0xfdd8('0x19')][_0xfdd8('0x18')]);}})[_0xfdd8('0x1a')](function(_0x289aa7){logger[_0xfdd8('0x17')](_0xfdd8('0x12'),_0x29d432,_0x289aa7);_0x505c3f(_0x289aa7);});});}exports[_0xfdd8('0x1b')]=function(_0x54d0e0){var _0x21492d=this;return new Promise(function(_0x2fcc07,_0x561b19){return db[_0xfdd8('0x1c')]['findAll']({'raw':_0x54d0e0[_0xfdd8('0x1d')]?_0x54d0e0[_0xfdd8('0x1d')][_0xfdd8('0x1e')]===undefined?!![]:![]:!![],'where':_0x54d0e0[_0xfdd8('0x1d')]?_0x54d0e0[_0xfdd8('0x1d')]['where']||null:null,'attributes':_0x54d0e0['options']?_0x54d0e0['options']['attributes']||null:null,'limit':_0x54d0e0['options']?_0x54d0e0[_0xfdd8('0x1d')][_0xfdd8('0x1f')]||null:null,'include':_0x54d0e0[_0xfdd8('0x1d')]?_0x54d0e0[_0xfdd8('0x1d')][_0xfdd8('0x20')]?_[_0xfdd8('0x21')](_0x54d0e0[_0xfdd8('0x1d')]['include'],function(_0x6777e7){return{'model':db[_0x6777e7[_0xfdd8('0x22')]],'as':_0x6777e7['as'],'attributes':_0x6777e7['attributes'],'include':_0x6777e7[_0xfdd8('0x20')]?_[_0xfdd8('0x21')](_0x6777e7[_0xfdd8('0x20')],function(_0x586f06){return{'model':db[_0x586f06[_0xfdd8('0x22')]],'as':_0x586f06['as'],'attributes':_0x586f06[_0xfdd8('0x23')],'include':_0x586f06[_0xfdd8('0x20')]?_['map'](_0x586f06['include'],function(_0x33542d){return{'model':db[_0x33542d[_0xfdd8('0x22')]],'as':_0x33542d['as'],'attributes':_0x33542d['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x16a71c){logger[_0xfdd8('0x11')](_0xfdd8('0x1b'),_0x54d0e0);logger['debug'](_0xfdd8('0x1b'),_0x54d0e0,JSON[_0xfdd8('0x16')](_0x16a71c));_0x2fcc07(_0x16a71c);})[_0xfdd8('0x1a')](function(_0x537745){logger[_0xfdd8('0x17')]('GetOpenchannelQueue',_0x537745[_0xfdd8('0x18')],_0x54d0e0);_0x561b19(_0x21492d[_0xfdd8('0x17')](0x1f4,_0x537745[_0xfdd8('0x18')]));});});};exports[_0xfdd8('0x24')]=function(_0x13e31b){var _0x658a10=this;return new Promise(function(_0x2011ff,_0x20ff72){return db[_0xfdd8('0x1c')][_0xfdd8('0x25')]({'raw':_0x13e31b[_0xfdd8('0x1d')]?_0x13e31b[_0xfdd8('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x13e31b[_0xfdd8('0x1d')]?_0x13e31b[_0xfdd8('0x1d')][_0xfdd8('0x26')]||null:null,'attributes':_0x13e31b[_0xfdd8('0x1d')]?_0x13e31b['options'][_0xfdd8('0x23')]||null:null,'include':_0x13e31b['options']?_0x13e31b[_0xfdd8('0x1d')][_0xfdd8('0x20')]?_[_0xfdd8('0x21')](_0x13e31b[_0xfdd8('0x1d')]['include'],function(_0x3cad95){return{'model':db[_0x3cad95[_0xfdd8('0x22')]],'as':_0x3cad95['as'],'attributes':_0x3cad95['attributes'],'include':_0x3cad95['include']?_[_0xfdd8('0x21')](_0x3cad95[_0xfdd8('0x20')],function(_0x3f9a38){return{'model':db[_0x3f9a38[_0xfdd8('0x22')]],'as':_0x3f9a38['as'],'attributes':_0x3f9a38[_0xfdd8('0x23')],'include':_0x3f9a38[_0xfdd8('0x20')]?_[_0xfdd8('0x21')](_0x3f9a38[_0xfdd8('0x20')],function(_0x352c88){return{'model':db[_0x352c88[_0xfdd8('0x22')]],'as':_0x352c88['as'],'attributes':_0x352c88[_0xfdd8('0x23')]};}):[]};}):[]};}):[]:[]})[_0xfdd8('0x10')](function(_0x459945){logger[_0xfdd8('0x11')](_0xfdd8('0x24'),_0x13e31b);logger[_0xfdd8('0x13')](_0xfdd8('0x24'),_0x13e31b,JSON[_0xfdd8('0x16')](_0x459945));_0x2011ff(_0x459945);})['catch'](function(_0x2d2327){logger['error']('ShowOpenchannelQueue',_0x2d2327[_0xfdd8('0x18')],_0x13e31b);_0x20ff72(_0x658a10[_0xfdd8('0x17')](0x1f4,_0x2d2327[_0xfdd8('0x18')]));});});};