af317d48b96d63e36d44fa5078a18e39f18461bd
[motion2.git] / server / api / cdr / cdr.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 _0x4f24=['stringify','error','code','message','info','result','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/logger','../../config/environment','http','Cdr,\x20%s,\x20%s','request\x20sent','debug','Cdr,\x20%s,\x20%s,\x20%s'];(function(_0x1c8341,_0x3a43b0){var _0x33b933=function(_0x2d34b1){while(--_0x2d34b1){_0x1c8341['push'](_0x1c8341['shift']());}};_0x33b933(++_0x3a43b0);}(_0x4f24,0x72));var _0x44f2=function(_0x45d55e,_0x2fede3){_0x45d55e=_0x45d55e-0x0;var _0x29812a=_0x4f24[_0x45d55e];return _0x29812a;};'use strict';var _=require(_0x44f2('0x0'));var util=require('util');var moment=require(_0x44f2('0x1'));var BPromise=require(_0x44f2('0x2'));var rs=require(_0x44f2('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x44f2('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x44f2('0x5'))('rpc');var config=require(_0x44f2('0x6'));var jayson=require('jayson/promise');var client=jayson['client'][_0x44f2('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x50ea58,_0x229904,_0x49a435){return new BPromise(function(_0x22b19f,_0xfd7fda){return client['request'](_0x50ea58,_0x49a435)['then'](function(_0x384e16){logger['info'](_0x44f2('0x8'),_0x229904,_0x44f2('0x9'));logger[_0x44f2('0xa')](_0x44f2('0xb'),_0x229904,_0x44f2('0x9'),JSON[_0x44f2('0xc')](_0x384e16));if(_0x384e16[_0x44f2('0xd')]){if(_0x384e16[_0x44f2('0xd')][_0x44f2('0xe')]===0x1f4){logger[_0x44f2('0xd')](_0x44f2('0x8'),_0x229904,_0x384e16[_0x44f2('0xd')][_0x44f2('0xf')]);return _0xfd7fda(_0x384e16[_0x44f2('0xd')][_0x44f2('0xf')]);}logger[_0x44f2('0xd')]('Cdr,\x20%s,\x20%s',_0x229904,_0x384e16[_0x44f2('0xd')][_0x44f2('0xf')]);return _0x22b19f(_0x384e16[_0x44f2('0xd')]['message']);}else{logger[_0x44f2('0x10')](_0x44f2('0x8'),_0x229904,_0x44f2('0x9'));_0x22b19f(_0x384e16[_0x44f2('0x11')][_0x44f2('0xf')]);}})['catch'](function(_0x2a7d6e){logger[_0x44f2('0xd')]('Cdr,\x20%s,\x20%s',_0x229904,_0x2a7d6e);_0xfd7fda(_0x2a7d6e);});});}