Built motion from commit d5e4af8c.|2.6.23
[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 _0xd8d7=['client','http','request','then','info','Automation,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','lodash','util','moment','bluebird','randomstring','rpc','jayson/promise'];(function(_0x5f2280,_0x202963){var _0xb2007c=function(_0x38b7c9){while(--_0x38b7c9){_0x5f2280['push'](_0x5f2280['shift']());}};_0xb2007c(++_0x202963);}(_0xd8d7,0x1d4));var _0x7d8d=function(_0xdbe2de,_0x3bdc5a){_0xdbe2de=_0xdbe2de-0x0;var _0x2facd7=_0xd8d7[_0xdbe2de];return _0x2facd7;};'use strict';var _=require(_0x7d8d('0x0'));var util=require(_0x7d8d('0x1'));var moment=require(_0x7d8d('0x2'));var BPromise=require(_0x7d8d('0x3'));var rs=require(_0x7d8d('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x7d8d('0x5'));var config=require('../../config/environment');var jayson=require(_0x7d8d('0x6'));var client=jayson[_0x7d8d('0x7')][_0x7d8d('0x8')]({'port':0x232a});function respondWithRpcPromise(_0xc39292,_0x2294c2,_0x3036a9){return new BPromise(function(_0x1bac2e,_0x506fcd){return client[_0x7d8d('0x9')](_0xc39292,_0x3036a9)[_0x7d8d('0xa')](function(_0x3e2f6e){logger[_0x7d8d('0xb')](_0x7d8d('0xc'),_0x2294c2,_0x7d8d('0xd'));logger[_0x7d8d('0xe')]('Automation,\x20%s,\x20%s,\x20%s',_0x2294c2,_0x7d8d('0xd'),JSON[_0x7d8d('0xf')](_0x3e2f6e));if(_0x3e2f6e[_0x7d8d('0x10')]){if(_0x3e2f6e[_0x7d8d('0x10')][_0x7d8d('0x11')]===0x1f4){logger['error'](_0x7d8d('0xc'),_0x2294c2,_0x3e2f6e[_0x7d8d('0x10')][_0x7d8d('0x12')]);return _0x506fcd(_0x3e2f6e[_0x7d8d('0x10')][_0x7d8d('0x12')]);}logger[_0x7d8d('0x10')]('Automation,\x20%s,\x20%s',_0x2294c2,_0x3e2f6e[_0x7d8d('0x10')][_0x7d8d('0x12')]);return _0x1bac2e(_0x3e2f6e[_0x7d8d('0x10')][_0x7d8d('0x12')]);}else{logger[_0x7d8d('0xb')]('Automation,\x20%s,\x20%s',_0x2294c2,_0x7d8d('0xd'));_0x1bac2e(_0x3e2f6e['result'][_0x7d8d('0x12')]);}})['catch'](function(_0x12588c){logger[_0x7d8d('0x10')](_0x7d8d('0xc'),_0x2294c2,_0x12588c);_0x506fcd(_0x12588c);});});}