28c09dc8d56cf19dabc5ef7cc82a7236486a0d76
[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 _0x34d8=['../../config/environment','jayson/promise','http','redis','localhost','socket.io-emitter','./openchannelQueue.socket','request','info','OpenchannelQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','GetOpenchannelQueue','OpenchannelQueue','findAll','options','raw','attributes','limit','map','model','include','then','find','where','ShowOpenchannelQueue','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils'];(function(_0x212fcc,_0x1a8867){var _0x4d8190=function(_0x347f7b){while(--_0x347f7b){_0x212fcc['push'](_0x212fcc['shift']());}};_0x4d8190(++_0x1a8867);}(_0x34d8,0x69));var _0x834d=function(_0x223e27,_0x4b9133){_0x223e27=_0x223e27-0x0;var _0x35f4db=_0x34d8[_0x223e27];return _0x35f4db;};'use strict';var _=require(_0x834d('0x0'));var util=require('util');var moment=require(_0x834d('0x1'));var BPromise=require(_0x834d('0x2'));var rs=require(_0x834d('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x834d('0x4'))['db'];var utils=require(_0x834d('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0x834d('0x6'));var jayson=require(_0x834d('0x7'));var client=jayson['client'][_0x834d('0x8')]({'port':0x232a});config[_0x834d('0x9')]=_['defaults'](config[_0x834d('0x9')],{'host':_0x834d('0xa'),'port':0x18eb});var socket=require(_0x834d('0xb'))(new Redis(config[_0x834d('0x9')]));require(_0x834d('0xc'))['register'](socket);function respondWithRpcPromise(_0x189df5,_0x60ee68,_0x24abda){return new BPromise(function(_0x589c0b,_0x972e68){return client[_0x834d('0xd')](_0x189df5,_0x24abda)['then'](function(_0x953504){logger[_0x834d('0xe')](_0x834d('0xf'),_0x60ee68,_0x834d('0x10'));logger[_0x834d('0x11')]('OpenchannelQueue,\x20%s,\x20%s,\x20%s',_0x60ee68,_0x834d('0x10'),JSON[_0x834d('0x12')](_0x953504));if(_0x953504[_0x834d('0x13')]){if(_0x953504[_0x834d('0x13')][_0x834d('0x14')]===0x1f4){logger['error']('OpenchannelQueue,\x20%s,\x20%s',_0x60ee68,_0x953504[_0x834d('0x13')][_0x834d('0x15')]);return _0x972e68(_0x953504[_0x834d('0x13')]['message']);}logger[_0x834d('0x13')]('OpenchannelQueue,\x20%s,\x20%s',_0x60ee68,_0x953504[_0x834d('0x13')][_0x834d('0x15')]);return _0x589c0b(_0x953504[_0x834d('0x13')][_0x834d('0x15')]);}else{logger['info'](_0x834d('0xf'),_0x60ee68,_0x834d('0x10'));_0x589c0b(_0x953504['result'][_0x834d('0x15')]);}})[_0x834d('0x16')](function(_0x29ce70){logger[_0x834d('0x13')]('OpenchannelQueue,\x20%s,\x20%s',_0x60ee68,_0x29ce70);_0x972e68(_0x29ce70);});});}exports[_0x834d('0x17')]=function(_0x3d7f5){var _0xa3c64a=this;return new Promise(function(_0x451035,_0x324352){return db[_0x834d('0x18')][_0x834d('0x19')]({'raw':_0x3d7f5[_0x834d('0x1a')]?_0x3d7f5[_0x834d('0x1a')][_0x834d('0x1b')]===undefined?!![]:![]:!![],'where':_0x3d7f5[_0x834d('0x1a')]?_0x3d7f5['options']['where']||null:null,'attributes':_0x3d7f5[_0x834d('0x1a')]?_0x3d7f5[_0x834d('0x1a')][_0x834d('0x1c')]||null:null,'limit':_0x3d7f5[_0x834d('0x1a')]?_0x3d7f5[_0x834d('0x1a')][_0x834d('0x1d')]||null:null,'include':_0x3d7f5[_0x834d('0x1a')]?_0x3d7f5[_0x834d('0x1a')]['include']?_[_0x834d('0x1e')](_0x3d7f5[_0x834d('0x1a')]['include'],function(_0x159c74){return{'model':db[_0x159c74[_0x834d('0x1f')]],'as':_0x159c74['as'],'attributes':_0x159c74[_0x834d('0x1c')],'include':_0x159c74[_0x834d('0x20')]?_['map'](_0x159c74[_0x834d('0x20')],function(_0x31d356){return{'model':db[_0x31d356[_0x834d('0x1f')]],'as':_0x31d356['as'],'attributes':_0x31d356[_0x834d('0x1c')],'include':_0x31d356['include']?_[_0x834d('0x1e')](_0x31d356[_0x834d('0x20')],function(_0x443808){return{'model':db[_0x443808[_0x834d('0x1f')]],'as':_0x443808['as'],'attributes':_0x443808[_0x834d('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x834d('0x21')](function(_0x5490a1){logger[_0x834d('0xe')](_0x834d('0x17'),_0x3d7f5);logger[_0x834d('0x11')]('GetOpenchannelQueue',_0x3d7f5,JSON[_0x834d('0x12')](_0x5490a1));_0x451035(_0x5490a1);})['catch'](function(_0xd54f3f){logger[_0x834d('0x13')](_0x834d('0x17'),_0xd54f3f[_0x834d('0x15')],_0x3d7f5);_0x324352(_0xa3c64a[_0x834d('0x13')](0x1f4,_0xd54f3f[_0x834d('0x15')]));});});};exports['ShowOpenchannelQueue']=function(_0x19ba12){var _0x5d3c30=this;return new Promise(function(_0x4740e0,_0x5d223d){return db[_0x834d('0x18')][_0x834d('0x22')]({'raw':_0x19ba12[_0x834d('0x1a')]?_0x19ba12[_0x834d('0x1a')][_0x834d('0x1b')]===undefined?!![]:![]:!![],'where':_0x19ba12[_0x834d('0x1a')]?_0x19ba12[_0x834d('0x1a')][_0x834d('0x23')]||null:null,'attributes':_0x19ba12[_0x834d('0x1a')]?_0x19ba12[_0x834d('0x1a')][_0x834d('0x1c')]||null:null,'include':_0x19ba12[_0x834d('0x1a')]?_0x19ba12[_0x834d('0x1a')][_0x834d('0x20')]?_[_0x834d('0x1e')](_0x19ba12[_0x834d('0x1a')][_0x834d('0x20')],function(_0x5115a7){return{'model':db[_0x5115a7[_0x834d('0x1f')]],'as':_0x5115a7['as'],'attributes':_0x5115a7[_0x834d('0x1c')],'include':_0x5115a7[_0x834d('0x20')]?_[_0x834d('0x1e')](_0x5115a7[_0x834d('0x20')],function(_0x4a2b66){return{'model':db[_0x4a2b66[_0x834d('0x1f')]],'as':_0x4a2b66['as'],'attributes':_0x4a2b66['attributes'],'include':_0x4a2b66['include']?_[_0x834d('0x1e')](_0x4a2b66[_0x834d('0x20')],function(_0x1f409e){return{'model':db[_0x1f409e['model']],'as':_0x1f409e['as'],'attributes':_0x1f409e[_0x834d('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x834d('0x21')](function(_0x2c31e2){logger[_0x834d('0xe')](_0x834d('0x24'),_0x19ba12);logger[_0x834d('0x11')](_0x834d('0x24'),_0x19ba12,JSON[_0x834d('0x12')](_0x2c31e2));_0x4740e0(_0x2c31e2);})[_0x834d('0x16')](function(_0x55026d){logger[_0x834d('0x13')]('ShowOpenchannelQueue',_0x55026d[_0x834d('0x15')],_0x19ba12);_0x5d223d(_0x5d3c30[_0x834d('0x13')](0x1f4,_0x55026d['message']));});});};