Built motion from commit (unavailable).|2.5.14
[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 _0x4c65=['catch','util','moment','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','http','request','then','info','request\x20sent','debug','Network,\x20%s,\x20%s,\x20%s','stringify','error','Network,\x20%s,\x20%s','message','result'];(function(_0xa12fe7,_0x170f78){var _0x49c20b=function(_0x3aeb26){while(--_0x3aeb26){_0xa12fe7['push'](_0xa12fe7['shift']());}};_0x49c20b(++_0x170f78);}(_0x4c65,0x119));var _0x54c6=function(_0x25c877,_0x1e47ff){_0x25c877=_0x25c877-0x0;var _0x45e3cf=_0x4c65[_0x25c877];return _0x45e3cf;};'use strict';var _=require('lodash');var util=require(_0x54c6('0x0'));var moment=require(_0x54c6('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x54c6('0x2'));var db=require(_0x54c6('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x54c6('0x4'))(_0x54c6('0x5'));var config=require(_0x54c6('0x6'));var jayson=require('jayson/promise');var client=jayson['client'][_0x54c6('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x79b57c,_0x2a5172,_0x2825d3){return new BPromise(function(_0x5ea732,_0x112b8f){return client[_0x54c6('0x8')](_0x79b57c,_0x2825d3)[_0x54c6('0x9')](function(_0xa4a1e7){logger[_0x54c6('0xa')]('Network,\x20%s,\x20%s',_0x2a5172,_0x54c6('0xb'));logger[_0x54c6('0xc')](_0x54c6('0xd'),_0x2a5172,_0x54c6('0xb'),JSON[_0x54c6('0xe')](_0xa4a1e7));if(_0xa4a1e7[_0x54c6('0xf')]){if(_0xa4a1e7[_0x54c6('0xf')]['code']===0x1f4){logger['error'](_0x54c6('0x10'),_0x2a5172,_0xa4a1e7[_0x54c6('0xf')]['message']);return _0x112b8f(_0xa4a1e7[_0x54c6('0xf')]['message']);}logger[_0x54c6('0xf')](_0x54c6('0x10'),_0x2a5172,_0xa4a1e7[_0x54c6('0xf')]['message']);return _0x5ea732(_0xa4a1e7[_0x54c6('0xf')][_0x54c6('0x11')]);}else{logger['info']('Network,\x20%s,\x20%s',_0x2a5172,'request\x20sent');_0x5ea732(_0xa4a1e7[_0x54c6('0x12')][_0x54c6('0x11')]);}})[_0x54c6('0x13')](function(_0x37d3b0){logger['error'](_0x54c6('0x10'),_0x2a5172,_0x37d3b0);_0x112b8f(_0x37d3b0);});});}