Built motion from commit e0fa946e.|2.6.5
[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 _0x9b96=['./openchannelQueue.socket','register','request','OpenchannelQueue,\x20%s,\x20%s,\x20%s','request\x20sent','error','OpenchannelQueue,\x20%s,\x20%s','message','info','result','GetOpenchannelQueue','OpenchannelQueue','findAll','options','where','attributes','limit','include','map','model','then','debug','stringify','find','ShowOpenchannelQueue','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter'];(function(_0x432682,_0x253044){var _0x463d05=function(_0xa73403){while(--_0xa73403){_0x432682['push'](_0x432682['shift']());}};_0x463d05(++_0x253044);}(_0x9b96,0x140));var _0x69b9=function(_0x2d7f0e,_0x3e6fbd){_0x2d7f0e=_0x2d7f0e-0x0;var _0x110b07=_0x9b96[_0x2d7f0e];return _0x110b07;};'use strict';var _=require(_0x69b9('0x0'));var util=require(_0x69b9('0x1'));var moment=require(_0x69b9('0x2'));var BPromise=require(_0x69b9('0x3'));var rs=require(_0x69b9('0x4'));var fs=require('fs');var Redis=require(_0x69b9('0x5'));var db=require(_0x69b9('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x69b9('0x7'))(_0x69b9('0x8'));var config=require('../../config/environment');var jayson=require(_0x69b9('0x9'));var client=jayson[_0x69b9('0xa')][_0x69b9('0xb')]({'port':0x232a});config[_0x69b9('0xc')]=_[_0x69b9('0xd')](config[_0x69b9('0xc')],{'host':_0x69b9('0xe'),'port':0x18eb});var socket=require(_0x69b9('0xf'))(new Redis(config['redis']));require(_0x69b9('0x10'))[_0x69b9('0x11')](socket);function respondWithRpcPromise(_0x85f3d2,_0x475b69,_0x1719b5){return new BPromise(function(_0x4fa90c,_0x402d8b){return client[_0x69b9('0x12')](_0x85f3d2,_0x1719b5)['then'](function(_0x542c48){logger['info']('OpenchannelQueue,\x20%s,\x20%s',_0x475b69,'request\x20sent');logger['debug'](_0x69b9('0x13'),_0x475b69,_0x69b9('0x14'),JSON['stringify'](_0x542c48));if(_0x542c48['error']){if(_0x542c48['error']['code']===0x1f4){logger[_0x69b9('0x15')](_0x69b9('0x16'),_0x475b69,_0x542c48[_0x69b9('0x15')][_0x69b9('0x17')]);return _0x402d8b(_0x542c48['error'][_0x69b9('0x17')]);}logger['error']('OpenchannelQueue,\x20%s,\x20%s',_0x475b69,_0x542c48[_0x69b9('0x15')]['message']);return _0x4fa90c(_0x542c48[_0x69b9('0x15')]['message']);}else{logger[_0x69b9('0x18')](_0x69b9('0x16'),_0x475b69,'request\x20sent');_0x4fa90c(_0x542c48[_0x69b9('0x19')][_0x69b9('0x17')]);}})['catch'](function(_0x3826f0){logger[_0x69b9('0x15')]('OpenchannelQueue,\x20%s,\x20%s',_0x475b69,_0x3826f0);_0x402d8b(_0x3826f0);});});}exports[_0x69b9('0x1a')]=function(_0x1951ab){var _0x322659=this;return new Promise(function(_0x3b402b,_0x2c58ac){return db[_0x69b9('0x1b')][_0x69b9('0x1c')]({'raw':_0x1951ab[_0x69b9('0x1d')]?_0x1951ab[_0x69b9('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x1951ab[_0x69b9('0x1d')]?_0x1951ab[_0x69b9('0x1d')][_0x69b9('0x1e')]||null:null,'attributes':_0x1951ab[_0x69b9('0x1d')]?_0x1951ab['options'][_0x69b9('0x1f')]||null:null,'limit':_0x1951ab[_0x69b9('0x1d')]?_0x1951ab[_0x69b9('0x1d')][_0x69b9('0x20')]||null:null,'include':_0x1951ab[_0x69b9('0x1d')]?_0x1951ab[_0x69b9('0x1d')][_0x69b9('0x21')]?_[_0x69b9('0x22')](_0x1951ab['options'][_0x69b9('0x21')],function(_0xf05fa6){return{'model':db[_0xf05fa6[_0x69b9('0x23')]],'as':_0xf05fa6['as'],'attributes':_0xf05fa6[_0x69b9('0x1f')],'include':_0xf05fa6[_0x69b9('0x21')]?_[_0x69b9('0x22')](_0xf05fa6['include'],function(_0x172b04){return{'model':db[_0x172b04[_0x69b9('0x23')]],'as':_0x172b04['as'],'attributes':_0x172b04[_0x69b9('0x1f')],'include':_0x172b04['include']?_['map'](_0x172b04['include'],function(_0x1ef670){return{'model':db[_0x1ef670['model']],'as':_0x1ef670['as'],'attributes':_0x1ef670['attributes']};}):[]};}):[]};}):[]:[]})[_0x69b9('0x24')](function(_0x37ca99){logger[_0x69b9('0x18')](_0x69b9('0x1a'),_0x1951ab);logger[_0x69b9('0x25')]('GetOpenchannelQueue',_0x1951ab,JSON[_0x69b9('0x26')](_0x37ca99));_0x3b402b(_0x37ca99);})['catch'](function(_0x5882c9){logger['error'](_0x69b9('0x1a'),_0x5882c9['message'],_0x1951ab);_0x2c58ac(_0x322659[_0x69b9('0x15')](0x1f4,_0x5882c9[_0x69b9('0x17')]));});});};exports['ShowOpenchannelQueue']=function(_0x13781f){var _0x8873af=this;return new Promise(function(_0x530588,_0x3dd95c){return db[_0x69b9('0x1b')][_0x69b9('0x27')]({'raw':_0x13781f[_0x69b9('0x1d')]?_0x13781f[_0x69b9('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x13781f[_0x69b9('0x1d')]?_0x13781f[_0x69b9('0x1d')][_0x69b9('0x1e')]||null:null,'attributes':_0x13781f[_0x69b9('0x1d')]?_0x13781f[_0x69b9('0x1d')]['attributes']||null:null,'include':_0x13781f[_0x69b9('0x1d')]?_0x13781f['options'][_0x69b9('0x21')]?_['map'](_0x13781f['options'][_0x69b9('0x21')],function(_0x220740){return{'model':db[_0x220740[_0x69b9('0x23')]],'as':_0x220740['as'],'attributes':_0x220740['attributes'],'include':_0x220740[_0x69b9('0x21')]?_[_0x69b9('0x22')](_0x220740[_0x69b9('0x21')],function(_0x7d51e6){return{'model':db[_0x7d51e6[_0x69b9('0x23')]],'as':_0x7d51e6['as'],'attributes':_0x7d51e6[_0x69b9('0x1f')],'include':_0x7d51e6['include']?_[_0x69b9('0x22')](_0x7d51e6[_0x69b9('0x21')],function(_0x436f79){return{'model':db[_0x436f79[_0x69b9('0x23')]],'as':_0x436f79['as'],'attributes':_0x436f79[_0x69b9('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x69b9('0x24')](function(_0xcd6288){logger[_0x69b9('0x18')](_0x69b9('0x28'),_0x13781f);logger['debug'](_0x69b9('0x28'),_0x13781f,JSON[_0x69b9('0x26')](_0xcd6288));_0x530588(_0xcd6288);})[_0x69b9('0x29')](function(_0x331dcb){logger[_0x69b9('0x15')](_0x69b9('0x28'),_0x331dcb[_0x69b9('0x17')],_0x13781f);_0x3dd95c(_0x8873af['error'](0x1f4,_0x331dcb[_0x69b9('0x17')]));});});};