4db165b20c5288c4548d2a6c9fc8e71bb03d0236
[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 _0x1236=['randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','http','redis','defaults','./cmList.socket','request','then','request\x20sent','debug','CmList,\x20%s,\x20%s,\x20%s','stringify','error','code','CmList,\x20%s,\x20%s','message','info','result','lodash','util','moment','bluebird'];(function(_0x19e35c,_0x29cd1e){var _0x3e1fe8=function(_0x17258b){while(--_0x17258b){_0x19e35c['push'](_0x19e35c['shift']());}};_0x3e1fe8(++_0x29cd1e);}(_0x1236,0xab));var _0x6123=function(_0x867b3a,_0x2fcc0d){_0x867b3a=_0x867b3a-0x0;var _0x2f0995=_0x1236[_0x867b3a];return _0x2f0995;};'use strict';var _=require(_0x6123('0x0'));var util=require(_0x6123('0x1'));var moment=require(_0x6123('0x2'));var BPromise=require(_0x6123('0x3'));var rs=require(_0x6123('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6123('0x5'))['db'];var utils=require(_0x6123('0x6'));var logger=require(_0x6123('0x7'))('rpc');var config=require(_0x6123('0x8'));var jayson=require('jayson/promise');var client=jayson['client'][_0x6123('0x9')]({'port':0x232a});config[_0x6123('0xa')]=_[_0x6123('0xb')](config[_0x6123('0xa')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x6123('0xa')]));require(_0x6123('0xc'))['register'](socket);function respondWithRpcPromise(_0x31d9a8,_0x15d66c,_0x42d8b9){return new BPromise(function(_0xe83225,_0x35fb21){return client[_0x6123('0xd')](_0x31d9a8,_0x42d8b9)[_0x6123('0xe')](function(_0x2dbd12){logger['info']('CmList,\x20%s,\x20%s',_0x15d66c,_0x6123('0xf'));logger[_0x6123('0x10')](_0x6123('0x11'),_0x15d66c,_0x6123('0xf'),JSON[_0x6123('0x12')](_0x2dbd12));if(_0x2dbd12['error']){if(_0x2dbd12[_0x6123('0x13')][_0x6123('0x14')]===0x1f4){logger[_0x6123('0x13')](_0x6123('0x15'),_0x15d66c,_0x2dbd12[_0x6123('0x13')]['message']);return _0x35fb21(_0x2dbd12[_0x6123('0x13')][_0x6123('0x16')]);}logger[_0x6123('0x13')]('CmList,\x20%s,\x20%s',_0x15d66c,_0x2dbd12[_0x6123('0x13')]['message']);return _0xe83225(_0x2dbd12['error'][_0x6123('0x16')]);}else{logger[_0x6123('0x17')](_0x6123('0x15'),_0x15d66c,_0x6123('0xf'));_0xe83225(_0x2dbd12[_0x6123('0x18')][_0x6123('0x16')]);}})['catch'](function(_0x2a2a30){logger['error'](_0x6123('0x15'),_0x15d66c,_0x2a2a30);_0x35fb21(_0x2a2a30);});});}