60a816160960e92ae5f4ed4d2fa595714c6a7f98
[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 _0xfba2=['catch','lodash','moment','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','request','then','info','Automation,\x20%s,\x20%s','request\x20sent','debug','Automation,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result'];(function(_0x5722ed,_0x2fb696){var _0x1b8933=function(_0x10a07b){while(--_0x10a07b){_0x5722ed['push'](_0x5722ed['shift']());}};_0x1b8933(++_0x2fb696);}(_0xfba2,0xbf));var _0x2fba=function(_0x25a778,_0x42d142){_0x25a778=_0x25a778-0x0;var _0x3abd14=_0xfba2[_0x25a778];return _0x3abd14;};'use strict';var _=require(_0x2fba('0x0'));var util=require('util');var moment=require(_0x2fba('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2fba('0x2'))['db'];var utils=require(_0x2fba('0x3'));var logger=require('../../config/logger')('rpc');var config=require(_0x2fba('0x4'));var jayson=require(_0x2fba('0x5'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x133bfa,_0x1a370e,_0xa33432){return new BPromise(function(_0xfb9ff4,_0x28204c){return client[_0x2fba('0x6')](_0x133bfa,_0xa33432)[_0x2fba('0x7')](function(_0x175b29){logger[_0x2fba('0x8')](_0x2fba('0x9'),_0x1a370e,_0x2fba('0xa'));logger[_0x2fba('0xb')](_0x2fba('0xc'),_0x1a370e,_0x2fba('0xa'),JSON[_0x2fba('0xd')](_0x175b29));if(_0x175b29[_0x2fba('0xe')]){if(_0x175b29['error'][_0x2fba('0xf')]===0x1f4){logger[_0x2fba('0xe')](_0x2fba('0x9'),_0x1a370e,_0x175b29['error'][_0x2fba('0x10')]);return _0x28204c(_0x175b29[_0x2fba('0xe')][_0x2fba('0x10')]);}logger[_0x2fba('0xe')](_0x2fba('0x9'),_0x1a370e,_0x175b29[_0x2fba('0xe')]['message']);return _0xfb9ff4(_0x175b29[_0x2fba('0xe')]['message']);}else{logger['info'](_0x2fba('0x9'),_0x1a370e,'request\x20sent');_0xfb9ff4(_0x175b29[_0x2fba('0x11')][_0x2fba('0x10')]);}})[_0x2fba('0x12')](function(_0x115d5a){logger[_0x2fba('0xe')]('Automation,\x20%s,\x20%s',_0x1a370e,_0x115d5a);_0x28204c(_0x115d5a);});});}