Built motion from commit (unavailable).|2.5.28
[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 _0xa941=['socket.io-emitter','./openchannelQueue.socket','register','request','then','info','request\x20sent','debug','stringify','error','OpenchannelQueue,\x20%s,\x20%s','message','result','OpenchannelQueue','findAll','options','raw','where','limit','map','include','model','attributes','GetOpenchannelQueue','ShowOpenchannelQueue','catch','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','jayson/promise','http','redis','defaults','localhost'];(function(_0x2363c5,_0x32f949){var _0x50b68f=function(_0x39dc0c){while(--_0x39dc0c){_0x2363c5['push'](_0x2363c5['shift']());}};_0x50b68f(++_0x32f949);}(_0xa941,0x1e2));var _0x1a94=function(_0x59ee6f,_0x450239){_0x59ee6f=_0x59ee6f-0x0;var _0x4c0979=_0xa941[_0x59ee6f];return _0x4c0979;};'use strict';var _=require(_0x1a94('0x0'));var util=require('util');var moment=require(_0x1a94('0x1'));var BPromise=require(_0x1a94('0x2'));var rs=require(_0x1a94('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x1a94('0x4'))['db'];var utils=require(_0x1a94('0x5'));var logger=require('../../config/logger')(_0x1a94('0x6'));var config=require('../../config/environment');var jayson=require(_0x1a94('0x7'));var client=jayson['client'][_0x1a94('0x8')]({'port':0x232a});config[_0x1a94('0x9')]=_[_0x1a94('0xa')](config[_0x1a94('0x9')],{'host':_0x1a94('0xb'),'port':0x18eb});var socket=require(_0x1a94('0xc'))(new Redis(config[_0x1a94('0x9')]));require(_0x1a94('0xd'))[_0x1a94('0xe')](socket);function respondWithRpcPromise(_0x49f95,_0x1d1117,_0x3ca25d){return new BPromise(function(_0x4f0b9a,_0x5a5eb1){return client[_0x1a94('0xf')](_0x49f95,_0x3ca25d)[_0x1a94('0x10')](function(_0x4943cf){logger[_0x1a94('0x11')]('OpenchannelQueue,\x20%s,\x20%s',_0x1d1117,_0x1a94('0x12'));logger[_0x1a94('0x13')]('OpenchannelQueue,\x20%s,\x20%s,\x20%s',_0x1d1117,_0x1a94('0x12'),JSON[_0x1a94('0x14')](_0x4943cf));if(_0x4943cf[_0x1a94('0x15')]){if(_0x4943cf[_0x1a94('0x15')]['code']===0x1f4){logger[_0x1a94('0x15')](_0x1a94('0x16'),_0x1d1117,_0x4943cf[_0x1a94('0x15')]['message']);return _0x5a5eb1(_0x4943cf[_0x1a94('0x15')][_0x1a94('0x17')]);}logger['error'](_0x1a94('0x16'),_0x1d1117,_0x4943cf['error'][_0x1a94('0x17')]);return _0x4f0b9a(_0x4943cf['error'][_0x1a94('0x17')]);}else{logger[_0x1a94('0x11')]('OpenchannelQueue,\x20%s,\x20%s',_0x1d1117,_0x1a94('0x12'));_0x4f0b9a(_0x4943cf[_0x1a94('0x18')][_0x1a94('0x17')]);}})['catch'](function(_0x119626){logger[_0x1a94('0x15')](_0x1a94('0x16'),_0x1d1117,_0x119626);_0x5a5eb1(_0x119626);});});}exports['GetOpenchannelQueue']=function(_0x883f67){var _0x47f222=this;return new Promise(function(_0x439b0c,_0x2b538a){return db[_0x1a94('0x19')][_0x1a94('0x1a')]({'raw':_0x883f67['options']?_0x883f67[_0x1a94('0x1b')][_0x1a94('0x1c')]===undefined?!![]:![]:!![],'where':_0x883f67[_0x1a94('0x1b')]?_0x883f67[_0x1a94('0x1b')][_0x1a94('0x1d')]||null:null,'attributes':_0x883f67[_0x1a94('0x1b')]?_0x883f67[_0x1a94('0x1b')]['attributes']||null:null,'limit':_0x883f67[_0x1a94('0x1b')]?_0x883f67[_0x1a94('0x1b')][_0x1a94('0x1e')]||null:null,'include':_0x883f67[_0x1a94('0x1b')]?_0x883f67['options']['include']?_[_0x1a94('0x1f')](_0x883f67[_0x1a94('0x1b')][_0x1a94('0x20')],function(_0x5a5423){return{'model':db[_0x5a5423[_0x1a94('0x21')]],'as':_0x5a5423['as'],'attributes':_0x5a5423[_0x1a94('0x22')],'include':_0x5a5423[_0x1a94('0x20')]?_[_0x1a94('0x1f')](_0x5a5423['include'],function(_0x2f39c0){return{'model':db[_0x2f39c0[_0x1a94('0x21')]],'as':_0x2f39c0['as'],'attributes':_0x2f39c0[_0x1a94('0x22')],'include':_0x2f39c0[_0x1a94('0x20')]?_[_0x1a94('0x1f')](_0x2f39c0[_0x1a94('0x20')],function(_0x135bf6){return{'model':db[_0x135bf6['model']],'as':_0x135bf6['as'],'attributes':_0x135bf6['attributes']};}):[]};}):[]};}):[]:[]})[_0x1a94('0x10')](function(_0x341904){logger[_0x1a94('0x11')]('GetOpenchannelQueue',_0x883f67);logger['debug'](_0x1a94('0x23'),_0x883f67,JSON[_0x1a94('0x14')](_0x341904));_0x439b0c(_0x341904);})['catch'](function(_0x10636a){logger[_0x1a94('0x15')](_0x1a94('0x23'),_0x10636a['message'],_0x883f67);_0x2b538a(_0x47f222['error'](0x1f4,_0x10636a['message']));});});};exports[_0x1a94('0x24')]=function(_0x4411c2){var _0x2ff19f=this;return new Promise(function(_0x8b5173,_0x4e8353){return db[_0x1a94('0x19')]['find']({'raw':_0x4411c2[_0x1a94('0x1b')]?_0x4411c2['options'][_0x1a94('0x1c')]===undefined?!![]:![]:!![],'where':_0x4411c2[_0x1a94('0x1b')]?_0x4411c2[_0x1a94('0x1b')]['where']||null:null,'attributes':_0x4411c2['options']?_0x4411c2['options']['attributes']||null:null,'include':_0x4411c2[_0x1a94('0x1b')]?_0x4411c2['options'][_0x1a94('0x20')]?_[_0x1a94('0x1f')](_0x4411c2[_0x1a94('0x1b')][_0x1a94('0x20')],function(_0x27e084){return{'model':db[_0x27e084['model']],'as':_0x27e084['as'],'attributes':_0x27e084[_0x1a94('0x22')],'include':_0x27e084['include']?_[_0x1a94('0x1f')](_0x27e084['include'],function(_0x109721){return{'model':db[_0x109721[_0x1a94('0x21')]],'as':_0x109721['as'],'attributes':_0x109721[_0x1a94('0x22')],'include':_0x109721[_0x1a94('0x20')]?_[_0x1a94('0x1f')](_0x109721[_0x1a94('0x20')],function(_0x286bb5){return{'model':db[_0x286bb5[_0x1a94('0x21')]],'as':_0x286bb5['as'],'attributes':_0x286bb5[_0x1a94('0x22')]};}):[]};}):[]};}):[]:[]})[_0x1a94('0x10')](function(_0x4f5c85){logger[_0x1a94('0x11')](_0x1a94('0x24'),_0x4411c2);logger['debug'](_0x1a94('0x24'),_0x4411c2,JSON[_0x1a94('0x14')](_0x4f5c85));_0x8b5173(_0x4f5c85);})[_0x1a94('0x25')](function(_0x40e258){logger[_0x1a94('0x15')](_0x1a94('0x24'),_0x40e258[_0x1a94('0x17')],_0x4411c2);_0x4e8353(_0x2ff19f[_0x1a94('0x15')](0x1f4,_0x40e258[_0x1a94('0x17')]));});});};