Built motion from commit da617fac.|2.6.6
[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 _0xf9b3=['debug','Cdr,\x20%s,\x20%s,\x20%s','stringify','error','code','message','Cdr,\x20%s,\x20%s','info','result','catch','lodash','util','bluebird','randomstring','rpc','../../config/environment','client','http','request','request\x20sent'];(function(_0x4ef151,_0x43c5ab){var _0x4141bf=function(_0x385ed4){while(--_0x385ed4){_0x4ef151['push'](_0x4ef151['shift']());}};_0x4141bf(++_0x43c5ab);}(_0xf9b3,0xbe));var _0x3f9b=function(_0x16f9e7,_0xc36467){_0x16f9e7=_0x16f9e7-0x0;var _0x5ab7d7=_0xf9b3[_0x16f9e7];return _0x5ab7d7;};'use strict';var _=require(_0x3f9b('0x0'));var util=require(_0x3f9b('0x1'));var moment=require('moment');var BPromise=require(_0x3f9b('0x2'));var rs=require(_0x3f9b('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x3f9b('0x4'));var config=require(_0x3f9b('0x5'));var jayson=require('jayson/promise');var client=jayson[_0x3f9b('0x6')][_0x3f9b('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x353284,_0x60c580,_0x47bc04){return new BPromise(function(_0x57bba5,_0x17148f){return client[_0x3f9b('0x8')](_0x353284,_0x47bc04)['then'](function(_0x32125e){logger['info']('Cdr,\x20%s,\x20%s',_0x60c580,_0x3f9b('0x9'));logger[_0x3f9b('0xa')](_0x3f9b('0xb'),_0x60c580,_0x3f9b('0x9'),JSON[_0x3f9b('0xc')](_0x32125e));if(_0x32125e[_0x3f9b('0xd')]){if(_0x32125e[_0x3f9b('0xd')][_0x3f9b('0xe')]===0x1f4){logger[_0x3f9b('0xd')]('Cdr,\x20%s,\x20%s',_0x60c580,_0x32125e[_0x3f9b('0xd')][_0x3f9b('0xf')]);return _0x17148f(_0x32125e['error'][_0x3f9b('0xf')]);}logger[_0x3f9b('0xd')](_0x3f9b('0x10'),_0x60c580,_0x32125e[_0x3f9b('0xd')]['message']);return _0x57bba5(_0x32125e['error']['message']);}else{logger[_0x3f9b('0x11')](_0x3f9b('0x10'),_0x60c580,'request\x20sent');_0x57bba5(_0x32125e[_0x3f9b('0x12')][_0x3f9b('0xf')]);}})[_0x3f9b('0x13')](function(_0x3f89e9){logger[_0x3f9b('0xd')](_0x3f9b('0x10'),_0x60c580,_0x3f89e9);_0x17148f(_0x3f89e9);});});}