8541d5c71b54c0f830c042ee1c0055c7a97a29d8
[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 _0xa397=['../../mysqldb','../../config/utils','rpc','jayson/promise','client','http','request','info','Cdr,\x20%s,\x20%s','Cdr,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','lodash','bluebird','randomstring','ioredis'];(function(_0x3a24f2,_0x441682){var _0x17c0da=function(_0x489016){while(--_0x489016){_0x3a24f2['push'](_0x3a24f2['shift']());}};_0x17c0da(++_0x441682);}(_0xa397,0x188));var _0x7a39=function(_0x20c2f8,_0x6ea91){_0x20c2f8=_0x20c2f8-0x0;var _0x3ce3fc=_0xa397[_0x20c2f8];return _0x3ce3fc;};'use strict';var _=require(_0x7a39('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x7a39('0x1'));var rs=require(_0x7a39('0x2'));var fs=require('fs');var Redis=require(_0x7a39('0x3'));var db=require(_0x7a39('0x4'))['db'];var utils=require(_0x7a39('0x5'));var logger=require('../../config/logger')(_0x7a39('0x6'));var config=require('../../config/environment');var jayson=require(_0x7a39('0x7'));var client=jayson[_0x7a39('0x8')][_0x7a39('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5d7acf,_0x396033,_0x4f5d4e){return new BPromise(function(_0x4f07a2,_0xad4c32){return client[_0x7a39('0xa')](_0x5d7acf,_0x4f5d4e)['then'](function(_0x38a573){logger[_0x7a39('0xb')](_0x7a39('0xc'),_0x396033,'request\x20sent');logger['debug'](_0x7a39('0xd'),_0x396033,'request\x20sent',JSON[_0x7a39('0xe')](_0x38a573));if(_0x38a573[_0x7a39('0xf')]){if(_0x38a573[_0x7a39('0xf')]['code']===0x1f4){logger[_0x7a39('0xf')](_0x7a39('0xc'),_0x396033,_0x38a573[_0x7a39('0xf')][_0x7a39('0x10')]);return _0xad4c32(_0x38a573[_0x7a39('0xf')][_0x7a39('0x10')]);}logger[_0x7a39('0xf')](_0x7a39('0xc'),_0x396033,_0x38a573[_0x7a39('0xf')][_0x7a39('0x10')]);return _0x4f07a2(_0x38a573[_0x7a39('0xf')][_0x7a39('0x10')]);}else{logger['info'](_0x7a39('0xc'),_0x396033,'request\x20sent');_0x4f07a2(_0x38a573['result'][_0x7a39('0x10')]);}})[_0x7a39('0x11')](function(_0x466742){logger[_0x7a39('0xf')](_0x7a39('0xc'),_0x396033,_0x466742);_0xad4c32(_0x466742);});});}