fde4fd82dd411482fa729ad52d9a6bf4fbdf3a20
[motion2.git] / server / api / dashboardItem / dashboardItem.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 _0x46c2=['message','catch','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','client','http','redis','./dashboardItem.socket','request','then','info','DashboardItem,\x20%s,\x20%s','request\x20sent','debug','DashboardItem,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x21d401,_0x392214){var _0xcac6e9=function(_0x582a0c){while(--_0x582a0c){_0x21d401['push'](_0x21d401['shift']());}};_0xcac6e9(++_0x392214);}(_0x46c2,0xff));var _0x246c=function(_0x516a6e,_0x3abade){_0x516a6e=_0x516a6e-0x0;var _0x353d41=_0x46c2[_0x516a6e];return _0x353d41;};'use strict';var _=require(_0x246c('0x0'));var util=require(_0x246c('0x1'));var moment=require(_0x246c('0x2'));var BPromise=require('bluebird');var rs=require(_0x246c('0x3'));var fs=require('fs');var Redis=require(_0x246c('0x4'));var db=require(_0x246c('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x246c('0x6'))('rpc');var config=require(_0x246c('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x246c('0x8')][_0x246c('0x9')]({'port':0x232a});config[_0x246c('0xa')]=_['defaults'](config[_0x246c('0xa')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x246c('0xb'))['register'](socket);function respondWithRpcPromise(_0x160306,_0x39e1a7,_0x1dce28){return new BPromise(function(_0x48c06c,_0x3659e0){return client[_0x246c('0xc')](_0x160306,_0x1dce28)[_0x246c('0xd')](function(_0x381a5e){logger[_0x246c('0xe')](_0x246c('0xf'),_0x39e1a7,_0x246c('0x10'));logger[_0x246c('0x11')](_0x246c('0x12'),_0x39e1a7,_0x246c('0x10'),JSON[_0x246c('0x13')](_0x381a5e));if(_0x381a5e[_0x246c('0x14')]){if(_0x381a5e[_0x246c('0x14')]['code']===0x1f4){logger['error'](_0x246c('0xf'),_0x39e1a7,_0x381a5e[_0x246c('0x14')][_0x246c('0x15')]);return _0x3659e0(_0x381a5e[_0x246c('0x14')][_0x246c('0x15')]);}logger[_0x246c('0x14')]('DashboardItem,\x20%s,\x20%s',_0x39e1a7,_0x381a5e['error'][_0x246c('0x15')]);return _0x48c06c(_0x381a5e[_0x246c('0x14')][_0x246c('0x15')]);}else{logger['info'](_0x246c('0xf'),_0x39e1a7,_0x246c('0x10'));_0x48c06c(_0x381a5e['result']['message']);}})[_0x246c('0x16')](function(_0x2451c7){logger[_0x246c('0x14')]('DashboardItem,\x20%s,\x20%s',_0x39e1a7,_0x2451c7);_0x3659e0(_0x2451c7);});});}