Built motion from commit e02f907f.|2.6.14
[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 _0x3798=['request\x20sent','debug','Cdr,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','request','then','Cdr,\x20%s,\x20%s'];(function(_0x1288b3,_0x45e5dd){var _0xa46a94=function(_0x235487){while(--_0x235487){_0x1288b3['push'](_0x1288b3['shift']());}};_0xa46a94(++_0x45e5dd);}(_0x3798,0xcf));var _0x8379=function(_0x352bfe,_0x3dcc6c){_0x352bfe=_0x352bfe-0x0;var _0x4c22ec=_0x3798[_0x352bfe];return _0x4c22ec;};'use strict';var _=require('lodash');var util=require(_0x8379('0x0'));var moment=require(_0x8379('0x1'));var BPromise=require(_0x8379('0x2'));var rs=require(_0x8379('0x3'));var fs=require('fs');var Redis=require(_0x8379('0x4'));var db=require(_0x8379('0x5'))['db'];var utils=require(_0x8379('0x6'));var logger=require('../../config/logger')(_0x8379('0x7'));var config=require(_0x8379('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x8379('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x55afba,_0x5537a8,_0x526eed){return new BPromise(function(_0x27d5a3,_0x4ce4cc){return client[_0x8379('0xa')](_0x55afba,_0x526eed)[_0x8379('0xb')](function(_0x329a7d){logger['info'](_0x8379('0xc'),_0x5537a8,_0x8379('0xd'));logger[_0x8379('0xe')](_0x8379('0xf'),_0x5537a8,'request\x20sent',JSON[_0x8379('0x10')](_0x329a7d));if(_0x329a7d[_0x8379('0x11')]){if(_0x329a7d['error'][_0x8379('0x12')]===0x1f4){logger['error']('Cdr,\x20%s,\x20%s',_0x5537a8,_0x329a7d[_0x8379('0x11')][_0x8379('0x13')]);return _0x4ce4cc(_0x329a7d[_0x8379('0x11')][_0x8379('0x13')]);}logger[_0x8379('0x11')](_0x8379('0xc'),_0x5537a8,_0x329a7d[_0x8379('0x11')]['message']);return _0x27d5a3(_0x329a7d[_0x8379('0x11')][_0x8379('0x13')]);}else{logger['info'](_0x8379('0xc'),_0x5537a8,_0x8379('0xd'));_0x27d5a3(_0x329a7d[_0x8379('0x14')][_0x8379('0x13')]);}})[_0x8379('0x15')](function(_0x3e087a){logger[_0x8379('0x11')](_0x8379('0xc'),_0x5537a8,_0x3e087a);_0x4ce4cc(_0x3e087a);});});}