2258959c86c1a9c1a4ed7704a4d93e497f9af88a
[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 _0x8708=['register','request','then','CmList,\x20%s,\x20%s','request\x20sent','debug','CmList,\x20%s,\x20%s,\x20%s','stringify','code','error','message','catch','lodash','util','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./cmList.socket'];(function(_0x100d4c,_0x1d1e60){var _0x1bce92=function(_0x2dcb8d){while(--_0x2dcb8d){_0x100d4c['push'](_0x100d4c['shift']());}};_0x1bce92(++_0x1d1e60);}(_0x8708,0x98));var _0x8870=function(_0x160c73,_0x2ee678){_0x160c73=_0x160c73-0x0;var _0xd9302=_0x8708[_0x160c73];return _0xd9302;};'use strict';var _=require(_0x8870('0x0'));var util=require(_0x8870('0x1'));var moment=require('moment');var BPromise=require(_0x8870('0x2'));var rs=require(_0x8870('0x3'));var fs=require('fs');var Redis=require(_0x8870('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x8870('0x5'));var logger=require(_0x8870('0x6'))(_0x8870('0x7'));var config=require(_0x8870('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x8870('0x9')][_0x8870('0xa')]({'port':0x232a});config[_0x8870('0xb')]=_[_0x8870('0xc')](config[_0x8870('0xb')],{'host':_0x8870('0xd'),'port':0x18eb});var socket=require(_0x8870('0xe'))(new Redis(config['redis']));require(_0x8870('0xf'))[_0x8870('0x10')](socket);function respondWithRpcPromise(_0xf5873d,_0x47479b,_0x213083){return new BPromise(function(_0x5dcadb,_0x42e9ea){return client[_0x8870('0x11')](_0xf5873d,_0x213083)[_0x8870('0x12')](function(_0x1dce2c){logger['info'](_0x8870('0x13'),_0x47479b,_0x8870('0x14'));logger[_0x8870('0x15')](_0x8870('0x16'),_0x47479b,_0x8870('0x14'),JSON[_0x8870('0x17')](_0x1dce2c));if(_0x1dce2c['error']){if(_0x1dce2c['error'][_0x8870('0x18')]===0x1f4){logger[_0x8870('0x19')](_0x8870('0x13'),_0x47479b,_0x1dce2c[_0x8870('0x19')][_0x8870('0x1a')]);return _0x42e9ea(_0x1dce2c[_0x8870('0x19')][_0x8870('0x1a')]);}logger[_0x8870('0x19')](_0x8870('0x13'),_0x47479b,_0x1dce2c[_0x8870('0x19')]['message']);return _0x5dcadb(_0x1dce2c[_0x8870('0x19')][_0x8870('0x1a')]);}else{logger['info'](_0x8870('0x13'),_0x47479b,_0x8870('0x14'));_0x5dcadb(_0x1dce2c['result']['message']);}})[_0x8870('0x1b')](function(_0xb045af){logger['error'](_0x8870('0x13'),_0x47479b,_0xb045af);_0x42e9ea(_0xb045af);});});}