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 _0x5e0b=['http','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','request','then','info','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','OpenchannelQueue,\x20%s,\x20%s','message','result','catch','OpenchannelQueue','findAll','options','where','attributes','limit','map','model','include','GetOpenchannelQueue','ShowOpenchannelQueue','find','raw','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client'];(function(_0x2b81f5,_0x4edaf7){var _0x3ad681=function(_0x2a255e){while(--_0x2a255e){_0x2b81f5['push'](_0x2b81f5['shift']());}};_0x3ad681(++_0x4edaf7);}(_0x5e0b,0x75));var _0xb5e0=function(_0x2650e9,_0xb91cc){_0x2650e9=_0x2650e9-0x0;var _0x3511c8=_0x5e0b[_0x2650e9];return _0x3511c8;};'use strict';var _=require(_0xb5e0('0x0'));var util=require(_0xb5e0('0x1'));var moment=require('moment');var BPromise=require(_0xb5e0('0x2'));var rs=require(_0xb5e0('0x3'));var fs=require('fs');var Redis=require(_0xb5e0('0x4'));var db=require(_0xb5e0('0x5'))['db'];var utils=require(_0xb5e0('0x6'));var logger=require(_0xb5e0('0x7'))(_0xb5e0('0x8'));var config=require(_0xb5e0('0x9'));var jayson=require(_0xb5e0('0xa'));var client=jayson[_0xb5e0('0xb')][_0xb5e0('0xc')]({'port':0x232a});config[_0xb5e0('0xd')]=_[_0xb5e0('0xe')](config[_0xb5e0('0xd')],{'host':_0xb5e0('0xf'),'port':0x18eb});var socket=require(_0xb5e0('0x10'))(new Redis(config[_0xb5e0('0xd')]));require(_0xb5e0('0x11'))['register'](socket);function respondWithRpcPromise(_0x2755f6,_0x41df13,_0x288e83){return new BPromise(function(_0x204930,_0x2a1f21){return client[_0xb5e0('0x12')](_0x2755f6,_0x288e83)[_0xb5e0('0x13')](function(_0x563a26){logger[_0xb5e0('0x14')]('OpenchannelQueue,\x20%s,\x20%s',_0x41df13,'request\x20sent');logger[_0xb5e0('0x15')](_0xb5e0('0x16'),_0x41df13,_0xb5e0('0x17'),JSON[_0xb5e0('0x18')](_0x563a26));if(_0x563a26[_0xb5e0('0x19')]){if(_0x563a26[_0xb5e0('0x19')]['code']===0x1f4){logger[_0xb5e0('0x19')](_0xb5e0('0x1a'),_0x41df13,_0x563a26[_0xb5e0('0x19')][_0xb5e0('0x1b')]);return _0x2a1f21(_0x563a26['error'][_0xb5e0('0x1b')]);}logger[_0xb5e0('0x19')](_0xb5e0('0x1a'),_0x41df13,_0x563a26['error'][_0xb5e0('0x1b')]);return _0x204930(_0x563a26[_0xb5e0('0x19')]['message']);}else{logger[_0xb5e0('0x14')](_0xb5e0('0x1a'),_0x41df13,'request\x20sent');_0x204930(_0x563a26[_0xb5e0('0x1c')][_0xb5e0('0x1b')]);}})[_0xb5e0('0x1d')](function(_0x41b038){logger[_0xb5e0('0x19')](_0xb5e0('0x1a'),_0x41df13,_0x41b038);_0x2a1f21(_0x41b038);});});}exports['GetOpenchannelQueue']=function(_0xcf78a){var _0x536229=this;return new Promise(function(_0x6e9b99,_0x2af232){return db[_0xb5e0('0x1e')][_0xb5e0('0x1f')]({'raw':_0xcf78a[_0xb5e0('0x20')]?_0xcf78a[_0xb5e0('0x20')]['raw']===undefined?!![]:![]:!![],'where':_0xcf78a[_0xb5e0('0x20')]?_0xcf78a[_0xb5e0('0x20')][_0xb5e0('0x21')]||null:null,'attributes':_0xcf78a['options']?_0xcf78a[_0xb5e0('0x20')][_0xb5e0('0x22')]||null:null,'limit':_0xcf78a[_0xb5e0('0x20')]?_0xcf78a[_0xb5e0('0x20')][_0xb5e0('0x23')]||null:null,'include':_0xcf78a[_0xb5e0('0x20')]?_0xcf78a[_0xb5e0('0x20')]['include']?_[_0xb5e0('0x24')](_0xcf78a[_0xb5e0('0x20')]['include'],function(_0x490c3a){return{'model':db[_0x490c3a[_0xb5e0('0x25')]],'as':_0x490c3a['as'],'attributes':_0x490c3a[_0xb5e0('0x22')],'include':_0x490c3a['include']?_[_0xb5e0('0x24')](_0x490c3a['include'],function(_0x4fdcc0){return{'model':db[_0x4fdcc0[_0xb5e0('0x25')]],'as':_0x4fdcc0['as'],'attributes':_0x4fdcc0[_0xb5e0('0x22')],'include':_0x4fdcc0[_0xb5e0('0x26')]?_['map'](_0x4fdcc0[_0xb5e0('0x26')],function(_0x49e8a4){return{'model':db[_0x49e8a4[_0xb5e0('0x25')]],'as':_0x49e8a4['as'],'attributes':_0x49e8a4[_0xb5e0('0x22')]};}):[]};}):[]};}):[]:[]})[_0xb5e0('0x13')](function(_0x232042){logger[_0xb5e0('0x14')](_0xb5e0('0x27'),_0xcf78a);logger[_0xb5e0('0x15')](_0xb5e0('0x27'),_0xcf78a,JSON[_0xb5e0('0x18')](_0x232042));_0x6e9b99(_0x232042);})[_0xb5e0('0x1d')](function(_0x4baadd){logger[_0xb5e0('0x19')]('GetOpenchannelQueue',_0x4baadd[_0xb5e0('0x1b')],_0xcf78a);_0x2af232(_0x536229[_0xb5e0('0x19')](0x1f4,_0x4baadd[_0xb5e0('0x1b')]));});});};exports[_0xb5e0('0x28')]=function(_0x53a6d6){var _0x5e4122=this;return new Promise(function(_0x3d6e73,_0x52879f){return db[_0xb5e0('0x1e')][_0xb5e0('0x29')]({'raw':_0x53a6d6[_0xb5e0('0x20')]?_0x53a6d6['options'][_0xb5e0('0x2a')]===undefined?!![]:![]:!![],'where':_0x53a6d6[_0xb5e0('0x20')]?_0x53a6d6['options'][_0xb5e0('0x21')]||null:null,'attributes':_0x53a6d6[_0xb5e0('0x20')]?_0x53a6d6[_0xb5e0('0x20')]['attributes']||null:null,'include':_0x53a6d6[_0xb5e0('0x20')]?_0x53a6d6[_0xb5e0('0x20')][_0xb5e0('0x26')]?_[_0xb5e0('0x24')](_0x53a6d6[_0xb5e0('0x20')]['include'],function(_0x1758ed){return{'model':db[_0x1758ed[_0xb5e0('0x25')]],'as':_0x1758ed['as'],'attributes':_0x1758ed['attributes'],'include':_0x1758ed['include']?_[_0xb5e0('0x24')](_0x1758ed[_0xb5e0('0x26')],function(_0x19834f){return{'model':db[_0x19834f[_0xb5e0('0x25')]],'as':_0x19834f['as'],'attributes':_0x19834f[_0xb5e0('0x22')],'include':_0x19834f[_0xb5e0('0x26')]?_['map'](_0x19834f['include'],function(_0x32b781){return{'model':db[_0x32b781[_0xb5e0('0x25')]],'as':_0x32b781['as'],'attributes':_0x32b781[_0xb5e0('0x22')]};}):[]};}):[]};}):[]:[]})[_0xb5e0('0x13')](function(_0xcf3901){logger[_0xb5e0('0x14')]('ShowOpenchannelQueue',_0x53a6d6);logger[_0xb5e0('0x15')]('ShowOpenchannelQueue',_0x53a6d6,JSON[_0xb5e0('0x18')](_0xcf3901));_0x3d6e73(_0xcf3901);})['catch'](function(_0x5671f0){logger[_0xb5e0('0x19')](_0xb5e0('0x28'),_0x5671f0[_0xb5e0('0x1b')],_0x53a6d6);_0x52879f(_0x5e4122[_0xb5e0('0x19')](0x1f4,_0x5671f0[_0xb5e0('0x1b')]));});});};