Built motion from commit 85328c08.|2.5.50
[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 _0x0570=['request','then','Automation,\x20%s,\x20%s','request\x20sent','debug','stringify','code','error','message','info','util','moment','bluebird','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','client','http'];(function(_0x58175c,_0x2d9373){var _0x55b88f=function(_0x13ed84){while(--_0x13ed84){_0x58175c['push'](_0x58175c['shift']());}};_0x55b88f(++_0x2d9373);}(_0x0570,0x172));var _0x0057=function(_0x5472cc,_0x35ef9c){_0x5472cc=_0x5472cc-0x0;var _0x4255cf=_0x0570[_0x5472cc];return _0x4255cf;};'use strict';var _=require('lodash');var util=require(_0x0057('0x0'));var moment=require(_0x0057('0x1'));var BPromise=require(_0x0057('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0057('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x0057('0x4'));var logger=require('../../config/logger')(_0x0057('0x5'));var config=require(_0x0057('0x6'));var jayson=require(_0x0057('0x7'));var client=jayson[_0x0057('0x8')][_0x0057('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5096e2,_0xc86734,_0x529f55){return new BPromise(function(_0x15d424,_0x2f9d7f){return client[_0x0057('0xa')](_0x5096e2,_0x529f55)[_0x0057('0xb')](function(_0x29b7c6){logger['info'](_0x0057('0xc'),_0xc86734,_0x0057('0xd'));logger[_0x0057('0xe')]('Automation,\x20%s,\x20%s,\x20%s',_0xc86734,_0x0057('0xd'),JSON[_0x0057('0xf')](_0x29b7c6));if(_0x29b7c6['error']){if(_0x29b7c6['error'][_0x0057('0x10')]===0x1f4){logger[_0x0057('0x11')](_0x0057('0xc'),_0xc86734,_0x29b7c6['error'][_0x0057('0x12')]);return _0x2f9d7f(_0x29b7c6[_0x0057('0x11')][_0x0057('0x12')]);}logger[_0x0057('0x11')]('Automation,\x20%s,\x20%s',_0xc86734,_0x29b7c6[_0x0057('0x11')][_0x0057('0x12')]);return _0x15d424(_0x29b7c6['error'][_0x0057('0x12')]);}else{logger[_0x0057('0x13')]('Automation,\x20%s,\x20%s',_0xc86734,_0x0057('0xd'));_0x15d424(_0x29b7c6['result'][_0x0057('0x12')]);}})['catch'](function(_0x4be851){logger[_0x0057('0x11')]('Automation,\x20%s,\x20%s',_0xc86734,_0x4be851);_0x2f9d7f(_0x4be851);});});}