108873aa0751eab17f0268337bc01f8c4b13a134
[motion2.git] / server / api / automation / automation.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 _0xb8a0=['request\x20sent','debug','Automation,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','moment','bluebird','ioredis','../../config/environment','jayson/promise','client','http','request','then','info','Automation,\x20%s,\x20%s'];(function(_0x4b055c,_0x4b870b){var _0x4b62bb=function(_0x4884c2){while(--_0x4884c2){_0x4b055c['push'](_0x4b055c['shift']());}};_0x4b62bb(++_0x4b870b);}(_0xb8a0,0x1d5));var _0x0b8a=function(_0x2e7eaa,_0x1702d9){_0x2e7eaa=_0x2e7eaa-0x0;var _0x33e095=_0xb8a0[_0x2e7eaa];return _0x33e095;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x0b8a('0x0'));var BPromise=require(_0x0b8a('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0b8a('0x2'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x0b8a('0x3'));var jayson=require(_0x0b8a('0x4'));var client=jayson[_0x0b8a('0x5')][_0x0b8a('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x3527dd,_0x4039c2,_0x33a5bd){return new BPromise(function(_0x463015,_0x29ebdc){return client[_0x0b8a('0x7')](_0x3527dd,_0x33a5bd)[_0x0b8a('0x8')](function(_0x478492){logger[_0x0b8a('0x9')](_0x0b8a('0xa'),_0x4039c2,_0x0b8a('0xb'));logger[_0x0b8a('0xc')](_0x0b8a('0xd'),_0x4039c2,_0x0b8a('0xb'),JSON[_0x0b8a('0xe')](_0x478492));if(_0x478492[_0x0b8a('0xf')]){if(_0x478492[_0x0b8a('0xf')][_0x0b8a('0x10')]===0x1f4){logger['error'](_0x0b8a('0xa'),_0x4039c2,_0x478492[_0x0b8a('0xf')][_0x0b8a('0x11')]);return _0x29ebdc(_0x478492[_0x0b8a('0xf')][_0x0b8a('0x11')]);}logger[_0x0b8a('0xf')](_0x0b8a('0xa'),_0x4039c2,_0x478492[_0x0b8a('0xf')][_0x0b8a('0x11')]);return _0x463015(_0x478492['error'][_0x0b8a('0x11')]);}else{logger[_0x0b8a('0x9')](_0x0b8a('0xa'),_0x4039c2,'request\x20sent');_0x463015(_0x478492[_0x0b8a('0x12')][_0x0b8a('0x11')]);}})[_0x0b8a('0x13')](function(_0x5a2623){logger['error']('Automation,\x20%s,\x20%s',_0x4039c2,_0x5a2623);_0x29ebdc(_0x5a2623);});});}