b38f2ecb3e908b805dd8112b37f8089acfcc5453
[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 _0x033e=['info','result','util','moment','bluebird','randomstring','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','Automation,\x20%s,\x20%s','request\x20sent','debug','Automation,\x20%s,\x20%s,\x20%s','error','code','message'];(function(_0x46d0c9,_0x526bfa){var _0x174506=function(_0x654bc6){while(--_0x654bc6){_0x46d0c9['push'](_0x46d0c9['shift']());}};_0x174506(++_0x526bfa);}(_0x033e,0x87));var _0xe033=function(_0x2f36a5,_0x167e18){_0x2f36a5=_0x2f36a5-0x0;var _0x2d7bd0=_0x033e[_0x2f36a5];return _0x2d7bd0;};'use strict';var _=require('lodash');var util=require(_0xe033('0x0'));var moment=require(_0xe033('0x1'));var BPromise=require(_0xe033('0x2'));var rs=require(_0xe033('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xe033('0x4'))(_0xe033('0x5'));var config=require(_0xe033('0x6'));var jayson=require(_0xe033('0x7'));var client=jayson['client'][_0xe033('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x34f894,_0x4dbab0,_0x66128b){return new BPromise(function(_0x50034f,_0x44d36e){return client['request'](_0x34f894,_0x66128b)[_0xe033('0x9')](function(_0x48e8c8){logger['info'](_0xe033('0xa'),_0x4dbab0,_0xe033('0xb'));logger[_0xe033('0xc')](_0xe033('0xd'),_0x4dbab0,'request\x20sent',JSON['stringify'](_0x48e8c8));if(_0x48e8c8[_0xe033('0xe')]){if(_0x48e8c8[_0xe033('0xe')][_0xe033('0xf')]===0x1f4){logger['error']('Automation,\x20%s,\x20%s',_0x4dbab0,_0x48e8c8[_0xe033('0xe')][_0xe033('0x10')]);return _0x44d36e(_0x48e8c8[_0xe033('0xe')]['message']);}logger[_0xe033('0xe')](_0xe033('0xa'),_0x4dbab0,_0x48e8c8[_0xe033('0xe')][_0xe033('0x10')]);return _0x50034f(_0x48e8c8[_0xe033('0xe')][_0xe033('0x10')]);}else{logger[_0xe033('0x11')](_0xe033('0xa'),_0x4dbab0,_0xe033('0xb'));_0x50034f(_0x48e8c8[_0xe033('0x12')][_0xe033('0x10')]);}})['catch'](function(_0x5ab505){logger[_0xe033('0xe')](_0xe033('0xa'),_0x4dbab0,_0x5ab505);_0x44d36e(_0x5ab505);});});}