8298c534cf811f1d8e11d225e122dae465b5964e
[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 _0x00a1=['moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Automation,\x20%s,\x20%s','request\x20sent','debug','Automation,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','lodash','util'];(function(_0x386b03,_0x5d0000){var _0xd3d524=function(_0x474754){while(--_0x474754){_0x386b03['push'](_0x386b03['shift']());}};_0xd3d524(++_0x5d0000);}(_0x00a1,0x7b));var _0x100a=function(_0x2ec589,_0x384cab){_0x2ec589=_0x2ec589-0x0;var _0x5cd6e9=_0x00a1[_0x2ec589];return _0x5cd6e9;};'use strict';var _=require(_0x100a('0x0'));var util=require(_0x100a('0x1'));var moment=require(_0x100a('0x2'));var BPromise=require(_0x100a('0x3'));var rs=require(_0x100a('0x4'));var fs=require('fs');var Redis=require(_0x100a('0x5'));var db=require(_0x100a('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x100a('0x7'))(_0x100a('0x8'));var config=require(_0x100a('0x9'));var jayson=require(_0x100a('0xa'));var client=jayson[_0x100a('0xb')][_0x100a('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x11faaa,_0x5874ac,_0xa660d0){return new BPromise(function(_0x3eea1a,_0x28f01c){return client[_0x100a('0xd')](_0x11faaa,_0xa660d0)[_0x100a('0xe')](function(_0xd799bd){logger[_0x100a('0xf')](_0x100a('0x10'),_0x5874ac,_0x100a('0x11'));logger[_0x100a('0x12')](_0x100a('0x13'),_0x5874ac,'request\x20sent',JSON[_0x100a('0x14')](_0xd799bd));if(_0xd799bd[_0x100a('0x15')]){if(_0xd799bd[_0x100a('0x15')]['code']===0x1f4){logger[_0x100a('0x15')](_0x100a('0x10'),_0x5874ac,_0xd799bd[_0x100a('0x15')][_0x100a('0x16')]);return _0x28f01c(_0xd799bd[_0x100a('0x15')][_0x100a('0x16')]);}logger[_0x100a('0x15')](_0x100a('0x10'),_0x5874ac,_0xd799bd[_0x100a('0x15')][_0x100a('0x16')]);return _0x3eea1a(_0xd799bd[_0x100a('0x15')][_0x100a('0x16')]);}else{logger[_0x100a('0xf')](_0x100a('0x10'),_0x5874ac,_0x100a('0x11'));_0x3eea1a(_0xd799bd[_0x100a('0x17')][_0x100a('0x16')]);}})[_0x100a('0x18')](function(_0x2c35d7){logger['error'](_0x100a('0x10'),_0x5874ac,_0x2c35d7);_0x28f01c(_0x2c35d7);});});}