1274e60f255eba528add3cb316b3b318cdd91479
[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 _0xf03a=['../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','request','then','Automation,\x20%s,\x20%s','request\x20sent','debug','Automation,\x20%s,\x20%s,\x20%s','error','code','message','info','result','util','moment','bluebird','randomstring'];(function(_0x3e1092,_0x1ca3e5){var _0x2380b5=function(_0xe31869){while(--_0xe31869){_0x3e1092['push'](_0x3e1092['shift']());}};_0x2380b5(++_0x1ca3e5);}(_0xf03a,0x1a0));var _0xaf03=function(_0x4f8a1a,_0xce04c){_0x4f8a1a=_0x4f8a1a-0x0;var _0x1b25d2=_0xf03a[_0x4f8a1a];return _0x1b25d2;};'use strict';var _=require('lodash');var util=require(_0xaf03('0x0'));var moment=require(_0xaf03('0x1'));var BPromise=require(_0xaf03('0x2'));var rs=require(_0xaf03('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xaf03('0x4'))['db'];var utils=require(_0xaf03('0x5'));var logger=require('../../config/logger')(_0xaf03('0x6'));var config=require(_0xaf03('0x7'));var jayson=require(_0xaf03('0x8'));var client=jayson[_0xaf03('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2d19df,_0x4d947f,_0x1dcf29){return new BPromise(function(_0x467e7c,_0x33a463){return client[_0xaf03('0xa')](_0x2d19df,_0x1dcf29)[_0xaf03('0xb')](function(_0x3a9083){logger['info'](_0xaf03('0xc'),_0x4d947f,_0xaf03('0xd'));logger[_0xaf03('0xe')](_0xaf03('0xf'),_0x4d947f,_0xaf03('0xd'),JSON['stringify'](_0x3a9083));if(_0x3a9083[_0xaf03('0x10')]){if(_0x3a9083[_0xaf03('0x10')][_0xaf03('0x11')]===0x1f4){logger[_0xaf03('0x10')](_0xaf03('0xc'),_0x4d947f,_0x3a9083[_0xaf03('0x10')][_0xaf03('0x12')]);return _0x33a463(_0x3a9083['error']['message']);}logger[_0xaf03('0x10')](_0xaf03('0xc'),_0x4d947f,_0x3a9083[_0xaf03('0x10')]['message']);return _0x467e7c(_0x3a9083['error'][_0xaf03('0x12')]);}else{logger[_0xaf03('0x13')](_0xaf03('0xc'),_0x4d947f,_0xaf03('0xd'));_0x467e7c(_0x3a9083[_0xaf03('0x14')][_0xaf03('0x12')]);}})['catch'](function(_0xcdc24){logger[_0xaf03('0x10')](_0xaf03('0xc'),_0x4d947f,_0xcdc24);_0x33a463(_0xcdc24);});});}