fcf3637015ebd6f60b12f9094a607275f8428305
[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 _0x8d1e=['code','error','message','result','GetOpenchannelQueue','findAll','options','raw','where','attributes','limit','include','map','model','catch','OpenchannelQueue','find','ShowOpenchannelQueue','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','request','then','info','OpenchannelQueue,\x20%s,\x20%s','request\x20sent','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x89247e,_0x2aa61b){var _0x56dfa2=function(_0x2931e0){while(--_0x2931e0){_0x89247e['push'](_0x89247e['shift']());}};_0x56dfa2(++_0x2aa61b);}(_0x8d1e,0x66));var _0xe8d1=function(_0x3b96cf,_0x1592f2){_0x3b96cf=_0x3b96cf-0x0;var _0x2e315a=_0x8d1e[_0x3b96cf];return _0x2e315a;};'use strict';var _=require(_0xe8d1('0x0'));var util=require(_0xe8d1('0x1'));var moment=require('moment');var BPromise=require(_0xe8d1('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xe8d1('0x3'));var db=require(_0xe8d1('0x4'))['db'];var utils=require(_0xe8d1('0x5'));var logger=require(_0xe8d1('0x6'))(_0xe8d1('0x7'));var config=require(_0xe8d1('0x8'));var jayson=require(_0xe8d1('0x9'));var client=jayson[_0xe8d1('0xa')]['http']({'port':0x232a});config[_0xe8d1('0xb')]=_[_0xe8d1('0xc')](config[_0xe8d1('0xb')],{'host':_0xe8d1('0xd'),'port':0x18eb});var socket=require(_0xe8d1('0xe'))(new Redis(config[_0xe8d1('0xb')]));require(_0xe8d1('0xf'))['register'](socket);function respondWithRpcPromise(_0x3a543a,_0x16bc5b,_0x3509b0){return new BPromise(function(_0x38df63,_0x3f5fb0){return client[_0xe8d1('0x10')](_0x3a543a,_0x3509b0)[_0xe8d1('0x11')](function(_0x4550fb){logger[_0xe8d1('0x12')](_0xe8d1('0x13'),_0x16bc5b,_0xe8d1('0x14'));logger[_0xe8d1('0x15')](_0xe8d1('0x16'),_0x16bc5b,_0xe8d1('0x14'),JSON[_0xe8d1('0x17')](_0x4550fb));if(_0x4550fb['error']){if(_0x4550fb['error'][_0xe8d1('0x18')]===0x1f4){logger[_0xe8d1('0x19')]('OpenchannelQueue,\x20%s,\x20%s',_0x16bc5b,_0x4550fb[_0xe8d1('0x19')][_0xe8d1('0x1a')]);return _0x3f5fb0(_0x4550fb[_0xe8d1('0x19')][_0xe8d1('0x1a')]);}logger['error']('OpenchannelQueue,\x20%s,\x20%s',_0x16bc5b,_0x4550fb[_0xe8d1('0x19')]['message']);return _0x38df63(_0x4550fb[_0xe8d1('0x19')]['message']);}else{logger['info'](_0xe8d1('0x13'),_0x16bc5b,_0xe8d1('0x14'));_0x38df63(_0x4550fb[_0xe8d1('0x1b')][_0xe8d1('0x1a')]);}})['catch'](function(_0x4e60f5){logger[_0xe8d1('0x19')]('OpenchannelQueue,\x20%s,\x20%s',_0x16bc5b,_0x4e60f5);_0x3f5fb0(_0x4e60f5);});});}exports[_0xe8d1('0x1c')]=function(_0x469efa){var _0x559d15=this;return new Promise(function(_0x3bcd99,_0x503a58){return db['OpenchannelQueue'][_0xe8d1('0x1d')]({'raw':_0x469efa[_0xe8d1('0x1e')]?_0x469efa[_0xe8d1('0x1e')][_0xe8d1('0x1f')]===undefined?!![]:![]:!![],'where':_0x469efa[_0xe8d1('0x1e')]?_0x469efa[_0xe8d1('0x1e')][_0xe8d1('0x20')]||null:null,'attributes':_0x469efa['options']?_0x469efa['options'][_0xe8d1('0x21')]||null:null,'limit':_0x469efa[_0xe8d1('0x1e')]?_0x469efa[_0xe8d1('0x1e')][_0xe8d1('0x22')]||null:null,'include':_0x469efa['options']?_0x469efa[_0xe8d1('0x1e')][_0xe8d1('0x23')]?_[_0xe8d1('0x24')](_0x469efa[_0xe8d1('0x1e')]['include'],function(_0x586a24){return{'model':db[_0x586a24[_0xe8d1('0x25')]],'as':_0x586a24['as'],'attributes':_0x586a24['attributes'],'include':_0x586a24[_0xe8d1('0x23')]?_[_0xe8d1('0x24')](_0x586a24[_0xe8d1('0x23')],function(_0x188a95){return{'model':db[_0x188a95[_0xe8d1('0x25')]],'as':_0x188a95['as'],'attributes':_0x188a95[_0xe8d1('0x21')],'include':_0x188a95['include']?_[_0xe8d1('0x24')](_0x188a95[_0xe8d1('0x23')],function(_0xbde825){return{'model':db[_0xbde825[_0xe8d1('0x25')]],'as':_0xbde825['as'],'attributes':_0xbde825[_0xe8d1('0x21')]};}):[]};}):[]};}):[]:[]})[_0xe8d1('0x11')](function(_0xee8002){logger['info']('GetOpenchannelQueue',_0x469efa);logger[_0xe8d1('0x15')](_0xe8d1('0x1c'),_0x469efa,JSON[_0xe8d1('0x17')](_0xee8002));_0x3bcd99(_0xee8002);})[_0xe8d1('0x26')](function(_0x3ffb5b){logger[_0xe8d1('0x19')](_0xe8d1('0x1c'),_0x3ffb5b[_0xe8d1('0x1a')],_0x469efa);_0x503a58(_0x559d15[_0xe8d1('0x19')](0x1f4,_0x3ffb5b['message']));});});};exports['ShowOpenchannelQueue']=function(_0x21e003){var _0x3539f8=this;return new Promise(function(_0x20d093,_0x29cfc9){return db[_0xe8d1('0x27')][_0xe8d1('0x28')]({'raw':_0x21e003['options']?_0x21e003[_0xe8d1('0x1e')][_0xe8d1('0x1f')]===undefined?!![]:![]:!![],'where':_0x21e003[_0xe8d1('0x1e')]?_0x21e003[_0xe8d1('0x1e')][_0xe8d1('0x20')]||null:null,'attributes':_0x21e003['options']?_0x21e003['options'][_0xe8d1('0x21')]||null:null,'include':_0x21e003[_0xe8d1('0x1e')]?_0x21e003['options'][_0xe8d1('0x23')]?_[_0xe8d1('0x24')](_0x21e003[_0xe8d1('0x1e')][_0xe8d1('0x23')],function(_0x3fbcd1){return{'model':db[_0x3fbcd1[_0xe8d1('0x25')]],'as':_0x3fbcd1['as'],'attributes':_0x3fbcd1[_0xe8d1('0x21')],'include':_0x3fbcd1[_0xe8d1('0x23')]?_['map'](_0x3fbcd1[_0xe8d1('0x23')],function(_0x5ed200){return{'model':db[_0x5ed200[_0xe8d1('0x25')]],'as':_0x5ed200['as'],'attributes':_0x5ed200[_0xe8d1('0x21')],'include':_0x5ed200[_0xe8d1('0x23')]?_[_0xe8d1('0x24')](_0x5ed200[_0xe8d1('0x23')],function(_0x1023f4){return{'model':db[_0x1023f4[_0xe8d1('0x25')]],'as':_0x1023f4['as'],'attributes':_0x1023f4['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x541267){logger[_0xe8d1('0x12')](_0xe8d1('0x29'),_0x21e003);logger['debug']('ShowOpenchannelQueue',_0x21e003,JSON[_0xe8d1('0x17')](_0x541267));_0x20d093(_0x541267);})[_0xe8d1('0x26')](function(_0x159f31){logger[_0xe8d1('0x19')](_0xe8d1('0x29'),_0x159f31[_0xe8d1('0x1a')],_0x21e003);_0x29cfc9(_0x3539f8['error'](0x1f4,_0x159f31['message']));});});};