8a19b219bac39f5437f0bf89418b258f8f1e1421
[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 _0x6fcf=['then','ShowOpenchannelQueue','find','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','redis','localhost','socket.io-emitter','./openchannelQueue.socket','register','request','info','OpenchannelQueue,\x20%s,\x20%s','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','GetOpenchannelQueue','OpenchannelQueue','options','where','attributes','limit','include','map','model'];(function(_0x216c52,_0x264f2f){var _0x485bea=function(_0x22899c){while(--_0x22899c){_0x216c52['push'](_0x216c52['shift']());}};_0x485bea(++_0x264f2f);}(_0x6fcf,0x1d7));var _0xf6fc=function(_0x3eb4a9,_0x359d73){_0x3eb4a9=_0x3eb4a9-0x0;var _0x48dbad=_0x6fcf[_0x3eb4a9];return _0x48dbad;};'use strict';var _=require(_0xf6fc('0x0'));var util=require('util');var moment=require(_0xf6fc('0x1'));var BPromise=require(_0xf6fc('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xf6fc('0x3'));var db=require(_0xf6fc('0x4'))['db'];var utils=require(_0xf6fc('0x5'));var logger=require(_0xf6fc('0x6'))(_0xf6fc('0x7'));var config=require('../../config/environment');var jayson=require(_0xf6fc('0x8'));var client=jayson[_0xf6fc('0x9')]['http']({'port':0x232a});config[_0xf6fc('0xa')]=_['defaults'](config[_0xf6fc('0xa')],{'host':_0xf6fc('0xb'),'port':0x18eb});var socket=require(_0xf6fc('0xc'))(new Redis(config[_0xf6fc('0xa')]));require(_0xf6fc('0xd'))[_0xf6fc('0xe')](socket);function respondWithRpcPromise(_0x5694e1,_0x13c90c,_0xa9ef26){return new BPromise(function(_0x371873,_0x194b31){return client[_0xf6fc('0xf')](_0x5694e1,_0xa9ef26)['then'](function(_0x292bcd){logger[_0xf6fc('0x10')](_0xf6fc('0x11'),_0x13c90c,'request\x20sent');logger[_0xf6fc('0x12')](_0xf6fc('0x13'),_0x13c90c,_0xf6fc('0x14'),JSON[_0xf6fc('0x15')](_0x292bcd));if(_0x292bcd[_0xf6fc('0x16')]){if(_0x292bcd[_0xf6fc('0x16')][_0xf6fc('0x17')]===0x1f4){logger['error']('OpenchannelQueue,\x20%s,\x20%s',_0x13c90c,_0x292bcd['error'][_0xf6fc('0x18')]);return _0x194b31(_0x292bcd['error'][_0xf6fc('0x18')]);}logger['error'](_0xf6fc('0x11'),_0x13c90c,_0x292bcd[_0xf6fc('0x16')]['message']);return _0x371873(_0x292bcd[_0xf6fc('0x16')]['message']);}else{logger[_0xf6fc('0x10')](_0xf6fc('0x11'),_0x13c90c,_0xf6fc('0x14'));_0x371873(_0x292bcd[_0xf6fc('0x19')]['message']);}})[_0xf6fc('0x1a')](function(_0x37fc1d){logger['error'](_0xf6fc('0x11'),_0x13c90c,_0x37fc1d);_0x194b31(_0x37fc1d);});});}exports[_0xf6fc('0x1b')]=function(_0x3fcc5b){var _0x4ca866=this;return new Promise(function(_0xdd470f,_0x4fa6ea){return db[_0xf6fc('0x1c')]['findAll']({'raw':_0x3fcc5b[_0xf6fc('0x1d')]?_0x3fcc5b['options']['raw']===undefined?!![]:![]:!![],'where':_0x3fcc5b[_0xf6fc('0x1d')]?_0x3fcc5b[_0xf6fc('0x1d')][_0xf6fc('0x1e')]||null:null,'attributes':_0x3fcc5b[_0xf6fc('0x1d')]?_0x3fcc5b['options'][_0xf6fc('0x1f')]||null:null,'limit':_0x3fcc5b[_0xf6fc('0x1d')]?_0x3fcc5b['options'][_0xf6fc('0x20')]||null:null,'include':_0x3fcc5b[_0xf6fc('0x1d')]?_0x3fcc5b[_0xf6fc('0x1d')][_0xf6fc('0x21')]?_[_0xf6fc('0x22')](_0x3fcc5b[_0xf6fc('0x1d')][_0xf6fc('0x21')],function(_0x5c7522){return{'model':db[_0x5c7522[_0xf6fc('0x23')]],'as':_0x5c7522['as'],'attributes':_0x5c7522[_0xf6fc('0x1f')],'include':_0x5c7522[_0xf6fc('0x21')]?_[_0xf6fc('0x22')](_0x5c7522[_0xf6fc('0x21')],function(_0x5b3bc8){return{'model':db[_0x5b3bc8['model']],'as':_0x5b3bc8['as'],'attributes':_0x5b3bc8['attributes'],'include':_0x5b3bc8[_0xf6fc('0x21')]?_[_0xf6fc('0x22')](_0x5b3bc8['include'],function(_0x23ee4b){return{'model':db[_0x23ee4b['model']],'as':_0x23ee4b['as'],'attributes':_0x23ee4b[_0xf6fc('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xf6fc('0x24')](function(_0x8d84cc){logger[_0xf6fc('0x10')](_0xf6fc('0x1b'),_0x3fcc5b);logger[_0xf6fc('0x12')]('GetOpenchannelQueue',_0x3fcc5b,JSON[_0xf6fc('0x15')](_0x8d84cc));_0xdd470f(_0x8d84cc);})[_0xf6fc('0x1a')](function(_0xa655f2){logger[_0xf6fc('0x16')](_0xf6fc('0x1b'),_0xa655f2[_0xf6fc('0x18')],_0x3fcc5b);_0x4fa6ea(_0x4ca866[_0xf6fc('0x16')](0x1f4,_0xa655f2[_0xf6fc('0x18')]));});});};exports[_0xf6fc('0x25')]=function(_0x45f5a9){var _0x56b2b5=this;return new Promise(function(_0x1f17fa,_0x29cc78){return db[_0xf6fc('0x1c')][_0xf6fc('0x26')]({'raw':_0x45f5a9[_0xf6fc('0x1d')]?_0x45f5a9[_0xf6fc('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x45f5a9['options']?_0x45f5a9[_0xf6fc('0x1d')][_0xf6fc('0x1e')]||null:null,'attributes':_0x45f5a9['options']?_0x45f5a9['options'][_0xf6fc('0x1f')]||null:null,'include':_0x45f5a9['options']?_0x45f5a9['options'][_0xf6fc('0x21')]?_[_0xf6fc('0x22')](_0x45f5a9['options'][_0xf6fc('0x21')],function(_0x1bf5a6){return{'model':db[_0x1bf5a6[_0xf6fc('0x23')]],'as':_0x1bf5a6['as'],'attributes':_0x1bf5a6[_0xf6fc('0x1f')],'include':_0x1bf5a6[_0xf6fc('0x21')]?_[_0xf6fc('0x22')](_0x1bf5a6['include'],function(_0x100b77){return{'model':db[_0x100b77[_0xf6fc('0x23')]],'as':_0x100b77['as'],'attributes':_0x100b77['attributes'],'include':_0x100b77[_0xf6fc('0x21')]?_[_0xf6fc('0x22')](_0x100b77[_0xf6fc('0x21')],function(_0xfc4145){return{'model':db[_0xfc4145[_0xf6fc('0x23')]],'as':_0xfc4145['as'],'attributes':_0xfc4145[_0xf6fc('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xf6fc('0x24')](function(_0x5ac41f){logger[_0xf6fc('0x10')](_0xf6fc('0x25'),_0x45f5a9);logger['debug'](_0xf6fc('0x25'),_0x45f5a9,JSON['stringify'](_0x5ac41f));_0x1f17fa(_0x5ac41f);})[_0xf6fc('0x1a')](function(_0x2ca09c){logger[_0xf6fc('0x16')](_0xf6fc('0x25'),_0x2ca09c[_0xf6fc('0x18')],_0x45f5a9);_0x29cc78(_0x56b2b5[_0xf6fc('0x16')](0x1f4,_0x2ca09c['message']));});});};