8af384b68882f9751db0a58005f370fb15136b4f
[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 _0xfcd4=['OpenchannelQueue,\x20%s,\x20%s','message','info','result','OpenchannelQueue','findAll','options','raw','attributes','limit','include','map','model','then','GetOpenchannelQueue','debug','catch','ShowOpenchannelQueue','find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','register','request\x20sent','stringify','error','code'];(function(_0x579aaa,_0xa6838c){var _0x40d71e=function(_0x313b38){while(--_0x313b38){_0x579aaa['push'](_0x579aaa['shift']());}};_0x40d71e(++_0xa6838c);}(_0xfcd4,0x109));var _0x4fcd=function(_0x55c3d9,_0x3bf75c){_0x55c3d9=_0x55c3d9-0x0;var _0x19fd97=_0xfcd4[_0x55c3d9];return _0x19fd97;};'use strict';var _=require(_0x4fcd('0x0'));var util=require(_0x4fcd('0x1'));var moment=require(_0x4fcd('0x2'));var BPromise=require(_0x4fcd('0x3'));var rs=require(_0x4fcd('0x4'));var fs=require('fs');var Redis=require(_0x4fcd('0x5'));var db=require(_0x4fcd('0x6'))['db'];var utils=require(_0x4fcd('0x7'));var logger=require(_0x4fcd('0x8'))('rpc');var config=require(_0x4fcd('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x4fcd('0xa')][_0x4fcd('0xb')]({'port':0x232a});config[_0x4fcd('0xc')]=_[_0x4fcd('0xd')](config['redis'],{'host':_0x4fcd('0xe'),'port':0x18eb});var socket=require(_0x4fcd('0xf'))(new Redis(config['redis']));require(_0x4fcd('0x10'))[_0x4fcd('0x11')](socket);function respondWithRpcPromise(_0x587329,_0x4d1e46,_0x285ec4){return new BPromise(function(_0x476e63,_0x5097ad){return client['request'](_0x587329,_0x285ec4)['then'](function(_0x3aecf1){logger['info']('OpenchannelQueue,\x20%s,\x20%s',_0x4d1e46,_0x4fcd('0x12'));logger['debug']('OpenchannelQueue,\x20%s,\x20%s,\x20%s',_0x4d1e46,_0x4fcd('0x12'),JSON[_0x4fcd('0x13')](_0x3aecf1));if(_0x3aecf1[_0x4fcd('0x14')]){if(_0x3aecf1[_0x4fcd('0x14')][_0x4fcd('0x15')]===0x1f4){logger[_0x4fcd('0x14')](_0x4fcd('0x16'),_0x4d1e46,_0x3aecf1[_0x4fcd('0x14')][_0x4fcd('0x17')]);return _0x5097ad(_0x3aecf1['error'][_0x4fcd('0x17')]);}logger[_0x4fcd('0x14')](_0x4fcd('0x16'),_0x4d1e46,_0x3aecf1['error'][_0x4fcd('0x17')]);return _0x476e63(_0x3aecf1['error'][_0x4fcd('0x17')]);}else{logger[_0x4fcd('0x18')]('OpenchannelQueue,\x20%s,\x20%s',_0x4d1e46,_0x4fcd('0x12'));_0x476e63(_0x3aecf1[_0x4fcd('0x19')][_0x4fcd('0x17')]);}})['catch'](function(_0x27cce1){logger[_0x4fcd('0x14')](_0x4fcd('0x16'),_0x4d1e46,_0x27cce1);_0x5097ad(_0x27cce1);});});}exports['GetOpenchannelQueue']=function(_0xc429f){var _0x3bc681=this;return new Promise(function(_0x3ff585,_0x51f404){return db[_0x4fcd('0x1a')][_0x4fcd('0x1b')]({'raw':_0xc429f[_0x4fcd('0x1c')]?_0xc429f[_0x4fcd('0x1c')][_0x4fcd('0x1d')]===undefined?!![]:![]:!![],'where':_0xc429f[_0x4fcd('0x1c')]?_0xc429f['options']['where']||null:null,'attributes':_0xc429f['options']?_0xc429f[_0x4fcd('0x1c')][_0x4fcd('0x1e')]||null:null,'limit':_0xc429f[_0x4fcd('0x1c')]?_0xc429f[_0x4fcd('0x1c')][_0x4fcd('0x1f')]||null:null,'include':_0xc429f['options']?_0xc429f['options'][_0x4fcd('0x20')]?_[_0x4fcd('0x21')](_0xc429f[_0x4fcd('0x1c')][_0x4fcd('0x20')],function(_0x572ac8){return{'model':db[_0x572ac8[_0x4fcd('0x22')]],'as':_0x572ac8['as'],'attributes':_0x572ac8[_0x4fcd('0x1e')],'include':_0x572ac8[_0x4fcd('0x20')]?_['map'](_0x572ac8[_0x4fcd('0x20')],function(_0x1bba06){return{'model':db[_0x1bba06['model']],'as':_0x1bba06['as'],'attributes':_0x1bba06[_0x4fcd('0x1e')],'include':_0x1bba06[_0x4fcd('0x20')]?_['map'](_0x1bba06[_0x4fcd('0x20')],function(_0x3bd498){return{'model':db[_0x3bd498[_0x4fcd('0x22')]],'as':_0x3bd498['as'],'attributes':_0x3bd498[_0x4fcd('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x4fcd('0x23')](function(_0x1c0c92){logger[_0x4fcd('0x18')](_0x4fcd('0x24'),_0xc429f);logger[_0x4fcd('0x25')]('GetOpenchannelQueue',_0xc429f,JSON[_0x4fcd('0x13')](_0x1c0c92));_0x3ff585(_0x1c0c92);})[_0x4fcd('0x26')](function(_0x32804f){logger[_0x4fcd('0x14')](_0x4fcd('0x24'),_0x32804f[_0x4fcd('0x17')],_0xc429f);_0x51f404(_0x3bc681[_0x4fcd('0x14')](0x1f4,_0x32804f[_0x4fcd('0x17')]));});});};exports[_0x4fcd('0x27')]=function(_0x54f426){var _0x8ddf1b=this;return new Promise(function(_0x5104a4,_0x280c3d){return db['OpenchannelQueue'][_0x4fcd('0x28')]({'raw':_0x54f426[_0x4fcd('0x1c')]?_0x54f426[_0x4fcd('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x54f426[_0x4fcd('0x1c')]?_0x54f426[_0x4fcd('0x1c')]['where']||null:null,'attributes':_0x54f426[_0x4fcd('0x1c')]?_0x54f426[_0x4fcd('0x1c')][_0x4fcd('0x1e')]||null:null,'include':_0x54f426['options']?_0x54f426[_0x4fcd('0x1c')][_0x4fcd('0x20')]?_[_0x4fcd('0x21')](_0x54f426[_0x4fcd('0x1c')][_0x4fcd('0x20')],function(_0x97a5c6){return{'model':db[_0x97a5c6[_0x4fcd('0x22')]],'as':_0x97a5c6['as'],'attributes':_0x97a5c6[_0x4fcd('0x1e')],'include':_0x97a5c6[_0x4fcd('0x20')]?_[_0x4fcd('0x21')](_0x97a5c6[_0x4fcd('0x20')],function(_0x3536c0){return{'model':db[_0x3536c0['model']],'as':_0x3536c0['as'],'attributes':_0x3536c0[_0x4fcd('0x1e')],'include':_0x3536c0[_0x4fcd('0x20')]?_[_0x4fcd('0x21')](_0x3536c0[_0x4fcd('0x20')],function(_0x53efa1){return{'model':db[_0x53efa1['model']],'as':_0x53efa1['as'],'attributes':_0x53efa1[_0x4fcd('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x445f30){logger['info']('ShowOpenchannelQueue',_0x54f426);logger[_0x4fcd('0x25')](_0x4fcd('0x27'),_0x54f426,JSON['stringify'](_0x445f30));_0x5104a4(_0x445f30);})['catch'](function(_0x27ff9f){logger[_0x4fcd('0x14')](_0x4fcd('0x27'),_0x27ff9f[_0x4fcd('0x17')],_0x54f426);_0x280c3d(_0x8ddf1b[_0x4fcd('0x14')](0x1f4,_0x27ff9f['message']));});});};