219a7b393704aaa31c4276ca9a54ce31d66c85a1
[motion2.git] / server / api / cmList / cmList.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 _0xacfb=['then','CmList,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','register','request'];(function(_0x732a7c,_0x4acf5b){var _0x11702d=function(_0x56fad9){while(--_0x56fad9){_0x732a7c['push'](_0x732a7c['shift']());}};_0x11702d(++_0x4acf5b);}(_0xacfb,0x1e4));var _0xbacf=function(_0x8bc2a6,_0x2a3337){_0x8bc2a6=_0x8bc2a6-0x0;var _0x2bf497=_0xacfb[_0x8bc2a6];return _0x2bf497;};'use strict';var _=require(_0xbacf('0x0'));var util=require(_0xbacf('0x1'));var moment=require(_0xbacf('0x2'));var BPromise=require(_0xbacf('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xbacf('0x4'));var db=require(_0xbacf('0x5'))['db'];var utils=require(_0xbacf('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0xbacf('0x7'));var jayson=require(_0xbacf('0x8'));var client=jayson[_0xbacf('0x9')]['http']({'port':0x232a});config[_0xbacf('0xa')]=_[_0xbacf('0xb')](config[_0xbacf('0xa')],{'host':_0xbacf('0xc'),'port':0x18eb});var socket=require(_0xbacf('0xd'))(new Redis(config[_0xbacf('0xa')]));require('./cmList.socket')[_0xbacf('0xe')](socket);function respondWithRpcPromise(_0x39df2a,_0x5e4178,_0x1d3484){return new BPromise(function(_0x13fe8d,_0x3a8bfe){return client[_0xbacf('0xf')](_0x39df2a,_0x1d3484)[_0xbacf('0x10')](function(_0x1834cd){logger['info'](_0xbacf('0x11'),_0x5e4178,_0xbacf('0x12'));logger['debug']('CmList,\x20%s,\x20%s,\x20%s',_0x5e4178,_0xbacf('0x12'),JSON[_0xbacf('0x13')](_0x1834cd));if(_0x1834cd['error']){if(_0x1834cd[_0xbacf('0x14')][_0xbacf('0x15')]===0x1f4){logger['error'](_0xbacf('0x11'),_0x5e4178,_0x1834cd[_0xbacf('0x14')][_0xbacf('0x16')]);return _0x3a8bfe(_0x1834cd['error']['message']);}logger['error'](_0xbacf('0x11'),_0x5e4178,_0x1834cd[_0xbacf('0x14')][_0xbacf('0x16')]);return _0x13fe8d(_0x1834cd[_0xbacf('0x14')][_0xbacf('0x16')]);}else{logger['info'](_0xbacf('0x11'),_0x5e4178,'request\x20sent');_0x13fe8d(_0x1834cd[_0xbacf('0x17')]['message']);}})[_0xbacf('0x18')](function(_0x47aa1f){logger[_0xbacf('0x14')](_0xbacf('0x11'),_0x5e4178,_0x47aa1f);_0x3a8bfe(_0x47aa1f);});});}