Built motion from commit (unavailable).|2.5.8
[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 _0xe961=['find','map','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','register','request','then','info','OpenchannelQueue,\x20%s,\x20%s','request\x20sent','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetOpenchannelQueue','OpenchannelQueue','options','attributes','limit','include','model','ShowOpenchannelQueue'];(function(_0x565ed7,_0x398228){var _0x183ad7=function(_0x5a43d7){while(--_0x5a43d7){_0x565ed7['push'](_0x565ed7['shift']());}};_0x183ad7(++_0x398228);}(_0xe961,0x74));var _0x1e96=function(_0x37bd26,_0x5ad346){_0x37bd26=_0x37bd26-0x0;var _0xe83dc4=_0xe961[_0x37bd26];return _0xe83dc4;};'use strict';var _=require(_0x1e96('0x0'));var util=require(_0x1e96('0x1'));var moment=require(_0x1e96('0x2'));var BPromise=require(_0x1e96('0x3'));var rs=require(_0x1e96('0x4'));var fs=require('fs');var Redis=require(_0x1e96('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x1e96('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0x1e96('0x7'));var jayson=require(_0x1e96('0x8'));var client=jayson[_0x1e96('0x9')][_0x1e96('0xa')]({'port':0x232a});config['redis']=_['defaults'](config[_0x1e96('0xb')],{'host':_0x1e96('0xc'),'port':0x18eb});var socket=require(_0x1e96('0xd'))(new Redis(config[_0x1e96('0xb')]));require('./openchannelQueue.socket')[_0x1e96('0xe')](socket);function respondWithRpcPromise(_0x1e9d0a,_0x4c34e7,_0x305b0f){return new BPromise(function(_0x43481b,_0x2338e4){return client[_0x1e96('0xf')](_0x1e9d0a,_0x305b0f)[_0x1e96('0x10')](function(_0x196b41){logger[_0x1e96('0x11')](_0x1e96('0x12'),_0x4c34e7,_0x1e96('0x13'));logger[_0x1e96('0x14')](_0x1e96('0x15'),_0x4c34e7,_0x1e96('0x13'),JSON[_0x1e96('0x16')](_0x196b41));if(_0x196b41[_0x1e96('0x17')]){if(_0x196b41[_0x1e96('0x17')][_0x1e96('0x18')]===0x1f4){logger[_0x1e96('0x17')](_0x1e96('0x12'),_0x4c34e7,_0x196b41[_0x1e96('0x17')]['message']);return _0x2338e4(_0x196b41['error'][_0x1e96('0x19')]);}logger[_0x1e96('0x17')](_0x1e96('0x12'),_0x4c34e7,_0x196b41['error'][_0x1e96('0x19')]);return _0x43481b(_0x196b41[_0x1e96('0x17')][_0x1e96('0x19')]);}else{logger[_0x1e96('0x11')](_0x1e96('0x12'),_0x4c34e7,_0x1e96('0x13'));_0x43481b(_0x196b41[_0x1e96('0x1a')][_0x1e96('0x19')]);}})[_0x1e96('0x1b')](function(_0x1be77c){logger['error']('OpenchannelQueue,\x20%s,\x20%s',_0x4c34e7,_0x1be77c);_0x2338e4(_0x1be77c);});});}exports[_0x1e96('0x1c')]=function(_0x2943a4){var _0x45fb78=this;return new Promise(function(_0x1eff96,_0x401975){return db[_0x1e96('0x1d')]['findAll']({'raw':_0x2943a4[_0x1e96('0x1e')]?_0x2943a4[_0x1e96('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x2943a4[_0x1e96('0x1e')]?_0x2943a4['options']['where']||null:null,'attributes':_0x2943a4[_0x1e96('0x1e')]?_0x2943a4[_0x1e96('0x1e')][_0x1e96('0x1f')]||null:null,'limit':_0x2943a4[_0x1e96('0x1e')]?_0x2943a4[_0x1e96('0x1e')][_0x1e96('0x20')]||null:null,'include':_0x2943a4[_0x1e96('0x1e')]?_0x2943a4['options'][_0x1e96('0x21')]?_['map'](_0x2943a4[_0x1e96('0x1e')]['include'],function(_0x3d35ce){return{'model':db[_0x3d35ce['model']],'as':_0x3d35ce['as'],'attributes':_0x3d35ce['attributes'],'include':_0x3d35ce[_0x1e96('0x21')]?_['map'](_0x3d35ce[_0x1e96('0x21')],function(_0x3cb826){return{'model':db[_0x3cb826[_0x1e96('0x22')]],'as':_0x3cb826['as'],'attributes':_0x3cb826[_0x1e96('0x1f')],'include':_0x3cb826[_0x1e96('0x21')]?_['map'](_0x3cb826['include'],function(_0x4e9436){return{'model':db[_0x4e9436[_0x1e96('0x22')]],'as':_0x4e9436['as'],'attributes':_0x4e9436[_0x1e96('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x1e96('0x10')](function(_0x5b6872){logger['info']('GetOpenchannelQueue',_0x2943a4);logger[_0x1e96('0x14')](_0x1e96('0x1c'),_0x2943a4,JSON[_0x1e96('0x16')](_0x5b6872));_0x1eff96(_0x5b6872);})[_0x1e96('0x1b')](function(_0x3f2a3a){logger['error']('GetOpenchannelQueue',_0x3f2a3a['message'],_0x2943a4);_0x401975(_0x45fb78[_0x1e96('0x17')](0x1f4,_0x3f2a3a[_0x1e96('0x19')]));});});};exports[_0x1e96('0x23')]=function(_0x2c7ca5){var _0x142e87=this;return new Promise(function(_0x17b547,_0x80f977){return db[_0x1e96('0x1d')][_0x1e96('0x24')]({'raw':_0x2c7ca5[_0x1e96('0x1e')]?_0x2c7ca5[_0x1e96('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x2c7ca5[_0x1e96('0x1e')]?_0x2c7ca5['options']['where']||null:null,'attributes':_0x2c7ca5[_0x1e96('0x1e')]?_0x2c7ca5[_0x1e96('0x1e')]['attributes']||null:null,'include':_0x2c7ca5[_0x1e96('0x1e')]?_0x2c7ca5[_0x1e96('0x1e')][_0x1e96('0x21')]?_[_0x1e96('0x25')](_0x2c7ca5[_0x1e96('0x1e')][_0x1e96('0x21')],function(_0x5ae41f){return{'model':db[_0x5ae41f[_0x1e96('0x22')]],'as':_0x5ae41f['as'],'attributes':_0x5ae41f[_0x1e96('0x1f')],'include':_0x5ae41f[_0x1e96('0x21')]?_[_0x1e96('0x25')](_0x5ae41f[_0x1e96('0x21')],function(_0x59824f){return{'model':db[_0x59824f[_0x1e96('0x22')]],'as':_0x59824f['as'],'attributes':_0x59824f[_0x1e96('0x1f')],'include':_0x59824f['include']?_['map'](_0x59824f['include'],function(_0x301003){return{'model':db[_0x301003[_0x1e96('0x22')]],'as':_0x301003['as'],'attributes':_0x301003[_0x1e96('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x1e96('0x10')](function(_0x2039ad){logger['info'](_0x1e96('0x23'),_0x2c7ca5);logger['debug'](_0x1e96('0x23'),_0x2c7ca5,JSON[_0x1e96('0x16')](_0x2039ad));_0x17b547(_0x2039ad);})[_0x1e96('0x1b')](function(_0x3f9752){logger['error'](_0x1e96('0x23'),_0x3f9752['message'],_0x2c7ca5);_0x80f977(_0x142e87[_0x1e96('0x17')](0x1f4,_0x3f9752[_0x1e96('0x19')]));});});};