Built motion from commit dc14b02d.|2.6.27
[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 _0xbfac=['request\x20sent','error','message','info','result','catch','util','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','Cdr,\x20%s,\x20%s'];(function(_0xb6c6f1,_0x12fa19){var _0xb8552f=function(_0x3b2dc7){while(--_0x3b2dc7){_0xb6c6f1['push'](_0xb6c6f1['shift']());}};_0xb8552f(++_0x12fa19);}(_0xbfac,0x110));var _0xcbfa=function(_0xff3bc2,_0x1d1b8e){_0xff3bc2=_0xff3bc2-0x0;var _0x18b857=_0xbfac[_0xff3bc2];return _0x18b857;};'use strict';var _=require('lodash');var util=require(_0xcbfa('0x0'));var moment=require(_0xcbfa('0x1'));var BPromise=require(_0xcbfa('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xcbfa('0x3'));var db=require(_0xcbfa('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xcbfa('0x5'))(_0xcbfa('0x6'));var config=require(_0xcbfa('0x7'));var jayson=require(_0xcbfa('0x8'));var client=jayson[_0xcbfa('0x9')][_0xcbfa('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x241c96,_0x25426a,_0x3e7494){return new BPromise(function(_0x395361,_0x19127a){return client[_0xcbfa('0xb')](_0x241c96,_0x3e7494)['then'](function(_0x49543f){logger['info'](_0xcbfa('0xc'),_0x25426a,_0xcbfa('0xd'));logger['debug']('Cdr,\x20%s,\x20%s,\x20%s',_0x25426a,'request\x20sent',JSON['stringify'](_0x49543f));if(_0x49543f['error']){if(_0x49543f[_0xcbfa('0xe')]['code']===0x1f4){logger['error'](_0xcbfa('0xc'),_0x25426a,_0x49543f[_0xcbfa('0xe')]['message']);return _0x19127a(_0x49543f[_0xcbfa('0xe')][_0xcbfa('0xf')]);}logger['error'](_0xcbfa('0xc'),_0x25426a,_0x49543f[_0xcbfa('0xe')][_0xcbfa('0xf')]);return _0x395361(_0x49543f[_0xcbfa('0xe')][_0xcbfa('0xf')]);}else{logger[_0xcbfa('0x10')](_0xcbfa('0xc'),_0x25426a,_0xcbfa('0xd'));_0x395361(_0x49543f[_0xcbfa('0x11')][_0xcbfa('0xf')]);}})[_0xcbfa('0x12')](function(_0xe56d5d){logger[_0xcbfa('0xe')](_0xcbfa('0xc'),_0x25426a,_0xe56d5d);_0x19127a(_0xe56d5d);});});}