f981d73f907140ecd686c43a39bdf70ff6ac438d
[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 _0xb79a=['util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','request','then','info','Automation,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','lodash'];(function(_0x23a395,_0x325e07){var _0x137d17=function(_0x457017){while(--_0x457017){_0x23a395['push'](_0x23a395['shift']());}};_0x137d17(++_0x325e07);}(_0xb79a,0x18e));var _0xab79=function(_0x2641f9,_0x26715f){_0x2641f9=_0x2641f9-0x0;var _0x585741=_0xb79a[_0x2641f9];return _0x585741;};'use strict';var _=require(_0xab79('0x0'));var util=require(_0xab79('0x1'));var moment=require('moment');var BPromise=require(_0xab79('0x2'));var rs=require(_0xab79('0x3'));var fs=require('fs');var Redis=require(_0xab79('0x4'));var db=require(_0xab79('0x5'))['db'];var utils=require(_0xab79('0x6'));var logger=require(_0xab79('0x7'))(_0xab79('0x8'));var config=require(_0xab79('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xab79('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0xe8ba5a,_0x10d402,_0x11ceb3){return new BPromise(function(_0x7eabd1,_0x4585fe){return client[_0xab79('0xb')](_0xe8ba5a,_0x11ceb3)[_0xab79('0xc')](function(_0x426cb9){logger[_0xab79('0xd')](_0xab79('0xe'),_0x10d402,_0xab79('0xf'));logger['debug']('Automation,\x20%s,\x20%s,\x20%s',_0x10d402,_0xab79('0xf'),JSON[_0xab79('0x10')](_0x426cb9));if(_0x426cb9[_0xab79('0x11')]){if(_0x426cb9[_0xab79('0x11')][_0xab79('0x12')]===0x1f4){logger[_0xab79('0x11')]('Automation,\x20%s,\x20%s',_0x10d402,_0x426cb9['error'][_0xab79('0x13')]);return _0x4585fe(_0x426cb9['error'][_0xab79('0x13')]);}logger[_0xab79('0x11')](_0xab79('0xe'),_0x10d402,_0x426cb9['error']['message']);return _0x7eabd1(_0x426cb9['error']['message']);}else{logger[_0xab79('0xd')](_0xab79('0xe'),_0x10d402,'request\x20sent');_0x7eabd1(_0x426cb9['result']['message']);}})[_0xab79('0x14')](function(_0xc9650d){logger['error'](_0xab79('0xe'),_0x10d402,_0xc9650d);_0x4585fe(_0xc9650d);});});}