0870a1ba800b2084dbfdd76cebaf4499c117e86b
[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 _0x93f4=['error','code','message','CmList,\x20%s,\x20%s','info','lodash','util','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./cmList.socket','register','request\x20sent','debug','CmList,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x93f4,0x69));var _0x493f=function(_0x23ad70,_0x279a80){_0x23ad70=_0x23ad70-0x0;var _0x39e32b=_0x93f4[_0x23ad70];return _0x39e32b;};'use strict';var _=require(_0x493f('0x0'));var util=require(_0x493f('0x1'));var moment=require('moment');var BPromise=require(_0x493f('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x493f('0x3'))['db'];var utils=require(_0x493f('0x4'));var logger=require(_0x493f('0x5'))(_0x493f('0x6'));var config=require(_0x493f('0x7'));var jayson=require(_0x493f('0x8'));var client=jayson[_0x493f('0x9')][_0x493f('0xa')]({'port':0x232a});config[_0x493f('0xb')]=_['defaults'](config[_0x493f('0xb')],{'host':_0x493f('0xc'),'port':0x18eb});var socket=require(_0x493f('0xd'))(new Redis(config['redis']));require(_0x493f('0xe'))[_0x493f('0xf')](socket);function respondWithRpcPromise(_0x18ebf7,_0x491458,_0x5eb525){return new BPromise(function(_0x4ec72f,_0x58c004){return client['request'](_0x18ebf7,_0x5eb525)['then'](function(_0x1f043d){logger['info']('CmList,\x20%s,\x20%s',_0x491458,_0x493f('0x10'));logger[_0x493f('0x11')](_0x493f('0x12'),_0x491458,'request\x20sent',JSON[_0x493f('0x13')](_0x1f043d));if(_0x1f043d[_0x493f('0x14')]){if(_0x1f043d['error'][_0x493f('0x15')]===0x1f4){logger[_0x493f('0x14')]('CmList,\x20%s,\x20%s',_0x491458,_0x1f043d[_0x493f('0x14')][_0x493f('0x16')]);return _0x58c004(_0x1f043d[_0x493f('0x14')][_0x493f('0x16')]);}logger[_0x493f('0x14')](_0x493f('0x17'),_0x491458,_0x1f043d[_0x493f('0x14')][_0x493f('0x16')]);return _0x4ec72f(_0x1f043d[_0x493f('0x14')][_0x493f('0x16')]);}else{logger[_0x493f('0x18')](_0x493f('0x17'),_0x491458,_0x493f('0x10'));_0x4ec72f(_0x1f043d['result'][_0x493f('0x16')]);}})['catch'](function(_0xa5578a){logger[_0x493f('0x14')]('CmList,\x20%s,\x20%s',_0x491458,_0xa5578a);_0x58c004(_0xa5578a);});});}