Built motion from commit 20b39a97.|2.6.29
[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 _0xf474=['then','OpenchannelQueue,\x20%s,\x20%s','request\x20sent','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','GetOpenchannelQueue','options','where','attributes','include','map','model','ShowOpenchannelQueue','OpenchannelQueue','find','raw','lodash','util','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter'];(function(_0x1694f5,_0x49b7c3){var _0x5b4321=function(_0x58c183){while(--_0x58c183){_0x1694f5['push'](_0x1694f5['shift']());}};_0x5b4321(++_0x49b7c3);}(_0xf474,0x89));var _0x4f47=function(_0xbd08b4,_0x4790ed){_0xbd08b4=_0xbd08b4-0x0;var _0x314f1e=_0xf474[_0xbd08b4];return _0x314f1e;};'use strict';var _=require(_0x4f47('0x0'));var util=require(_0x4f47('0x1'));var moment=require('moment');var BPromise=require(_0x4f47('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x4f47('0x3'))['db'];var utils=require(_0x4f47('0x4'));var logger=require(_0x4f47('0x5'))(_0x4f47('0x6'));var config=require(_0x4f47('0x7'));var jayson=require(_0x4f47('0x8'));var client=jayson[_0x4f47('0x9')][_0x4f47('0xa')]({'port':0x232a});config[_0x4f47('0xb')]=_[_0x4f47('0xc')](config[_0x4f47('0xb')],{'host':_0x4f47('0xd'),'port':0x18eb});var socket=require(_0x4f47('0xe'))(new Redis(config[_0x4f47('0xb')]));require('./openchannelQueue.socket')['register'](socket);function respondWithRpcPromise(_0x5ac6a5,_0x10f1d8,_0x4c14f3){return new BPromise(function(_0x598797,_0x4ecb67){return client['request'](_0x5ac6a5,_0x4c14f3)[_0x4f47('0xf')](function(_0x2c5970){logger['info'](_0x4f47('0x10'),_0x10f1d8,_0x4f47('0x11'));logger[_0x4f47('0x12')](_0x4f47('0x13'),_0x10f1d8,_0x4f47('0x11'),JSON[_0x4f47('0x14')](_0x2c5970));if(_0x2c5970['error']){if(_0x2c5970[_0x4f47('0x15')][_0x4f47('0x16')]===0x1f4){logger[_0x4f47('0x15')](_0x4f47('0x10'),_0x10f1d8,_0x2c5970[_0x4f47('0x15')][_0x4f47('0x17')]);return _0x4ecb67(_0x2c5970['error'][_0x4f47('0x17')]);}logger[_0x4f47('0x15')](_0x4f47('0x10'),_0x10f1d8,_0x2c5970[_0x4f47('0x15')][_0x4f47('0x17')]);return _0x598797(_0x2c5970['error'][_0x4f47('0x17')]);}else{logger[_0x4f47('0x18')](_0x4f47('0x10'),_0x10f1d8,_0x4f47('0x11'));_0x598797(_0x2c5970[_0x4f47('0x19')][_0x4f47('0x17')]);}})[_0x4f47('0x1a')](function(_0x1c9ca8){logger[_0x4f47('0x15')](_0x4f47('0x10'),_0x10f1d8,_0x1c9ca8);_0x4ecb67(_0x1c9ca8);});});}exports[_0x4f47('0x1b')]=function(_0x4fbff0){var _0x47c3b8=this;return new Promise(function(_0x481cd6,_0x4a576e){return db['OpenchannelQueue']['findAll']({'raw':_0x4fbff0[_0x4f47('0x1c')]?_0x4fbff0['options']['raw']===undefined?!![]:![]:!![],'where':_0x4fbff0[_0x4f47('0x1c')]?_0x4fbff0['options'][_0x4f47('0x1d')]||null:null,'attributes':_0x4fbff0[_0x4f47('0x1c')]?_0x4fbff0[_0x4f47('0x1c')][_0x4f47('0x1e')]||null:null,'limit':_0x4fbff0[_0x4f47('0x1c')]?_0x4fbff0[_0x4f47('0x1c')]['limit']||null:null,'include':_0x4fbff0[_0x4f47('0x1c')]?_0x4fbff0[_0x4f47('0x1c')][_0x4f47('0x1f')]?_[_0x4f47('0x20')](_0x4fbff0[_0x4f47('0x1c')]['include'],function(_0x366519){return{'model':db[_0x366519['model']],'as':_0x366519['as'],'attributes':_0x366519['attributes'],'include':_0x366519[_0x4f47('0x1f')]?_[_0x4f47('0x20')](_0x366519['include'],function(_0x2706fc){return{'model':db[_0x2706fc[_0x4f47('0x21')]],'as':_0x2706fc['as'],'attributes':_0x2706fc[_0x4f47('0x1e')],'include':_0x2706fc[_0x4f47('0x1f')]?_[_0x4f47('0x20')](_0x2706fc[_0x4f47('0x1f')],function(_0x2a6903){return{'model':db[_0x2a6903['model']],'as':_0x2a6903['as'],'attributes':_0x2a6903[_0x4f47('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x180ed6){logger[_0x4f47('0x18')](_0x4f47('0x1b'),_0x4fbff0);logger['debug'](_0x4f47('0x1b'),_0x4fbff0,JSON['stringify'](_0x180ed6));_0x481cd6(_0x180ed6);})['catch'](function(_0x2c3279){logger['error']('GetOpenchannelQueue',_0x2c3279['message'],_0x4fbff0);_0x4a576e(_0x47c3b8[_0x4f47('0x15')](0x1f4,_0x2c3279[_0x4f47('0x17')]));});});};exports[_0x4f47('0x22')]=function(_0x4700b8){var _0x48d2cb=this;return new Promise(function(_0x3d8704,_0x3f47eb){return db[_0x4f47('0x23')][_0x4f47('0x24')]({'raw':_0x4700b8[_0x4f47('0x1c')]?_0x4700b8['options'][_0x4f47('0x25')]===undefined?!![]:![]:!![],'where':_0x4700b8[_0x4f47('0x1c')]?_0x4700b8['options'][_0x4f47('0x1d')]||null:null,'attributes':_0x4700b8['options']?_0x4700b8[_0x4f47('0x1c')]['attributes']||null:null,'include':_0x4700b8[_0x4f47('0x1c')]?_0x4700b8[_0x4f47('0x1c')]['include']?_[_0x4f47('0x20')](_0x4700b8[_0x4f47('0x1c')][_0x4f47('0x1f')],function(_0x5784f3){return{'model':db[_0x5784f3[_0x4f47('0x21')]],'as':_0x5784f3['as'],'attributes':_0x5784f3['attributes'],'include':_0x5784f3[_0x4f47('0x1f')]?_[_0x4f47('0x20')](_0x5784f3[_0x4f47('0x1f')],function(_0x68e999){return{'model':db[_0x68e999[_0x4f47('0x21')]],'as':_0x68e999['as'],'attributes':_0x68e999['attributes'],'include':_0x68e999[_0x4f47('0x1f')]?_[_0x4f47('0x20')](_0x68e999[_0x4f47('0x1f')],function(_0x8830a8){return{'model':db[_0x8830a8[_0x4f47('0x21')]],'as':_0x8830a8['as'],'attributes':_0x8830a8[_0x4f47('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2e38d3){logger[_0x4f47('0x18')](_0x4f47('0x22'),_0x4700b8);logger['debug'](_0x4f47('0x22'),_0x4700b8,JSON[_0x4f47('0x14')](_0x2e38d3));_0x3d8704(_0x2e38d3);})[_0x4f47('0x1a')](function(_0x2e5612){logger[_0x4f47('0x15')](_0x4f47('0x22'),_0x2e5612[_0x4f47('0x17')],_0x4700b8);_0x3f47eb(_0x48d2cb['error'](0x1f4,_0x2e5612[_0x4f47('0x17')]));});});};