Built motion from commit 1fa89557.|2.6.10
[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 _0x66b7=['Cdr,\x20%s,\x20%s','message','info','result','catch','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','request','then','request\x20sent','debug','Cdr,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x1dba84,_0x1764b2){var _0x26f406=function(_0x13f345){while(--_0x13f345){_0x1dba84['push'](_0x1dba84['shift']());}};_0x26f406(++_0x1764b2);}(_0x66b7,0x1a7));var _0x766b=function(_0x5b174b,_0x404869){_0x5b174b=_0x5b174b-0x0;var _0x47ee37=_0x66b7[_0x5b174b];return _0x47ee37;};'use strict';var _=require('lodash');var util=require(_0x766b('0x0'));var moment=require(_0x766b('0x1'));var BPromise=require(_0x766b('0x2'));var rs=require(_0x766b('0x3'));var fs=require('fs');var Redis=require(_0x766b('0x4'));var db=require(_0x766b('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x766b('0x6'))('rpc');var config=require(_0x766b('0x7'));var jayson=require(_0x766b('0x8'));var client=jayson[_0x766b('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x566925,_0x35e8b5,_0xa3e537){return new BPromise(function(_0x4df7e9,_0x17812b){return client[_0x766b('0xa')](_0x566925,_0xa3e537)[_0x766b('0xb')](function(_0x75d77){logger['info']('Cdr,\x20%s,\x20%s',_0x35e8b5,_0x766b('0xc'));logger[_0x766b('0xd')](_0x766b('0xe'),_0x35e8b5,'request\x20sent',JSON[_0x766b('0xf')](_0x75d77));if(_0x75d77['error']){if(_0x75d77['error']['code']===0x1f4){logger[_0x766b('0x10')](_0x766b('0x11'),_0x35e8b5,_0x75d77['error']['message']);return _0x17812b(_0x75d77[_0x766b('0x10')][_0x766b('0x12')]);}logger[_0x766b('0x10')](_0x766b('0x11'),_0x35e8b5,_0x75d77[_0x766b('0x10')][_0x766b('0x12')]);return _0x4df7e9(_0x75d77[_0x766b('0x10')][_0x766b('0x12')]);}else{logger[_0x766b('0x13')](_0x766b('0x11'),_0x35e8b5,_0x766b('0xc'));_0x4df7e9(_0x75d77[_0x766b('0x14')][_0x766b('0x12')]);}})[_0x766b('0x15')](function(_0x59ad2d){logger[_0x766b('0x10')]('Cdr,\x20%s,\x20%s',_0x35e8b5,_0x59ad2d);_0x17812b(_0x59ad2d);});});}