Built motion from commit 14588770.|2.5.38
[motion2.git] / server / api / dashboard / dashboard.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 _0xce63=['stringify','error','code','message','info','catch','lodash','util','randomstring','../../config/utils','../../config/logger','jayson/promise','client','http','redis','defaults','localhost','./dashboard.socket','register','request','then','Dashboard,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xce63,0x186));var _0x3ce6=function(_0x2b49bc,_0x47b636){_0x2b49bc=_0x2b49bc-0x0;var _0x43cc65=_0xce63[_0x2b49bc];return _0x43cc65;};'use strict';var _=require(_0x3ce6('0x0'));var util=require(_0x3ce6('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x3ce6('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x3ce6('0x3'));var logger=require(_0x3ce6('0x4'))('rpc');var config=require('../../config/environment');var jayson=require(_0x3ce6('0x5'));var client=jayson[_0x3ce6('0x6')][_0x3ce6('0x7')]({'port':0x232a});config[_0x3ce6('0x8')]=_[_0x3ce6('0x9')](config[_0x3ce6('0x8')],{'host':_0x3ce6('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x3ce6('0x8')]));require(_0x3ce6('0xb'))[_0x3ce6('0xc')](socket);function respondWithRpcPromise(_0x174b2e,_0x4afee9,_0x2d559d){return new BPromise(function(_0x43feb2,_0x3cb217){return client[_0x3ce6('0xd')](_0x174b2e,_0x2d559d)[_0x3ce6('0xe')](function(_0x7c4305){logger['info'](_0x3ce6('0xf'),_0x4afee9,_0x3ce6('0x10'));logger[_0x3ce6('0x11')]('Dashboard,\x20%s,\x20%s,\x20%s',_0x4afee9,_0x3ce6('0x10'),JSON[_0x3ce6('0x12')](_0x7c4305));if(_0x7c4305[_0x3ce6('0x13')]){if(_0x7c4305[_0x3ce6('0x13')][_0x3ce6('0x14')]===0x1f4){logger[_0x3ce6('0x13')]('Dashboard,\x20%s,\x20%s',_0x4afee9,_0x7c4305[_0x3ce6('0x13')]['message']);return _0x3cb217(_0x7c4305['error'][_0x3ce6('0x15')]);}logger[_0x3ce6('0x13')](_0x3ce6('0xf'),_0x4afee9,_0x7c4305['error'][_0x3ce6('0x15')]);return _0x43feb2(_0x7c4305[_0x3ce6('0x13')][_0x3ce6('0x15')]);}else{logger[_0x3ce6('0x16')](_0x3ce6('0xf'),_0x4afee9,'request\x20sent');_0x43feb2(_0x7c4305['result'][_0x3ce6('0x15')]);}})[_0x3ce6('0x17')](function(_0x3ba6c9){logger[_0x3ce6('0x13')]('Dashboard,\x20%s,\x20%s',_0x4afee9,_0x3ba6c9);_0x3cb217(_0x3ba6c9);});});}