a971b7221e3806d33d6960502b02aa198e0253c9
[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 _0x9f44=['jayson/promise','client','http','redis','defaults','localhost','./cmList.socket','register','request','then','info','CmList,\x20%s,\x20%s','request\x20sent','debug','CmList,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x26eb9e,_0x5acbc3){var _0x3f4505=function(_0x414084){while(--_0x414084){_0x26eb9e['push'](_0x26eb9e['shift']());}};_0x3f4505(++_0x5acbc3);}(_0x9f44,0x15f));var _0x49f4=function(_0x9c2427,_0x17c865){_0x9c2427=_0x9c2427-0x0;var _0x51984f=_0x9f44[_0x9c2427];return _0x51984f;};'use strict';var _=require('lodash');var util=require(_0x49f4('0x0'));var moment=require(_0x49f4('0x1'));var BPromise=require(_0x49f4('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x49f4('0x3'));var db=require(_0x49f4('0x4'))['db'];var utils=require(_0x49f4('0x5'));var logger=require(_0x49f4('0x6'))(_0x49f4('0x7'));var config=require(_0x49f4('0x8'));var jayson=require(_0x49f4('0x9'));var client=jayson[_0x49f4('0xa')][_0x49f4('0xb')]({'port':0x232a});config[_0x49f4('0xc')]=_[_0x49f4('0xd')](config['redis'],{'host':_0x49f4('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x49f4('0xf'))[_0x49f4('0x10')](socket);function respondWithRpcPromise(_0x42b5a3,_0x2d3162,_0x371c71){return new BPromise(function(_0x1d87b8,_0x388b88){return client[_0x49f4('0x11')](_0x42b5a3,_0x371c71)[_0x49f4('0x12')](function(_0x55b93f){logger[_0x49f4('0x13')](_0x49f4('0x14'),_0x2d3162,_0x49f4('0x15'));logger[_0x49f4('0x16')](_0x49f4('0x17'),_0x2d3162,'request\x20sent',JSON[_0x49f4('0x18')](_0x55b93f));if(_0x55b93f[_0x49f4('0x19')]){if(_0x55b93f['error'][_0x49f4('0x1a')]===0x1f4){logger[_0x49f4('0x19')](_0x49f4('0x14'),_0x2d3162,_0x55b93f['error'][_0x49f4('0x1b')]);return _0x388b88(_0x55b93f[_0x49f4('0x19')]['message']);}logger[_0x49f4('0x19')](_0x49f4('0x14'),_0x2d3162,_0x55b93f[_0x49f4('0x19')][_0x49f4('0x1b')]);return _0x1d87b8(_0x55b93f[_0x49f4('0x19')]['message']);}else{logger['info'](_0x49f4('0x14'),_0x2d3162,_0x49f4('0x15'));_0x1d87b8(_0x55b93f[_0x49f4('0x1c')][_0x49f4('0x1b')]);}})[_0x49f4('0x1d')](function(_0x225e7f){logger[_0x49f4('0x19')](_0x49f4('0x14'),_0x2d3162,_0x225e7f);_0x388b88(_0x225e7f);});});}