af024f4a63ec00eb7d0d49d92ec00996a191dde6
[motion2.git] / server / api / network / network.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 _0x98e7=['message','result','catch','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','info','Network,\x20%s,\x20%s','debug','request\x20sent','stringify','code','error'];(function(_0x161733,_0xa82809){var _0x3f6938=function(_0x2a5f37){while(--_0x2a5f37){_0x161733['push'](_0x161733['shift']());}};_0x3f6938(++_0xa82809);}(_0x98e7,0xc0));var _0x798e=function(_0x3bf148,_0x1683ef){_0x3bf148=_0x3bf148-0x0;var _0x511781=_0x98e7[_0x3bf148];return _0x511781;};'use strict';var _=require('lodash');var util=require(_0x798e('0x0'));var moment=require(_0x798e('0x1'));var BPromise=require(_0x798e('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x798e('0x3'));var db=require(_0x798e('0x4'))['db'];var utils=require(_0x798e('0x5'));var logger=require(_0x798e('0x6'))('rpc');var config=require(_0x798e('0x7'));var jayson=require(_0x798e('0x8'));var client=jayson[_0x798e('0x9')][_0x798e('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x1a7a30,_0x3f799e,_0xf903fb){return new BPromise(function(_0x58810d,_0x2e706f){return client['request'](_0x1a7a30,_0xf903fb)['then'](function(_0x300444){logger[_0x798e('0xb')](_0x798e('0xc'),_0x3f799e,'request\x20sent');logger[_0x798e('0xd')]('Network,\x20%s,\x20%s,\x20%s',_0x3f799e,_0x798e('0xe'),JSON[_0x798e('0xf')](_0x300444));if(_0x300444['error']){if(_0x300444['error'][_0x798e('0x10')]===0x1f4){logger[_0x798e('0x11')](_0x798e('0xc'),_0x3f799e,_0x300444[_0x798e('0x11')][_0x798e('0x12')]);return _0x2e706f(_0x300444[_0x798e('0x11')][_0x798e('0x12')]);}logger[_0x798e('0x11')]('Network,\x20%s,\x20%s',_0x3f799e,_0x300444['error'][_0x798e('0x12')]);return _0x58810d(_0x300444[_0x798e('0x11')]['message']);}else{logger[_0x798e('0xb')](_0x798e('0xc'),_0x3f799e,_0x798e('0xe'));_0x58810d(_0x300444[_0x798e('0x13')]['message']);}})[_0x798e('0x14')](function(_0x829e54){logger['error'](_0x798e('0xc'),_0x3f799e,_0x829e54);_0x2e706f(_0x829e54);});});}