33098cab9b063fa443a4042f127fadf97dcdf573
[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 _0x4c05=['catch','lodash','util','moment','../../mysqldb','../../config/logger','jayson/promise','client','http','then','info','Automation,\x20%s,\x20%s','debug','Automation,\x20%s,\x20%s,\x20%s','stringify','error','message','request\x20sent','result'];(function(_0x546ab6,_0x357f23){var _0x3952ca=function(_0x29dcfa){while(--_0x29dcfa){_0x546ab6['push'](_0x546ab6['shift']());}};_0x3952ca(++_0x357f23);}(_0x4c05,0xac));var _0x54c0=function(_0x7b6c19,_0x3fe77b){_0x7b6c19=_0x7b6c19-0x0;var _0x217094=_0x4c05[_0x7b6c19];return _0x217094;};'use strict';var _=require(_0x54c0('0x0'));var util=require(_0x54c0('0x1'));var moment=require(_0x54c0('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x54c0('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x54c0('0x4'))('rpc');var config=require('../../config/environment');var jayson=require(_0x54c0('0x5'));var client=jayson[_0x54c0('0x6')][_0x54c0('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x75311,_0x4bec90,_0x137530){return new BPromise(function(_0x66cd15,_0x27b874){return client['request'](_0x75311,_0x137530)[_0x54c0('0x8')](function(_0x169411){logger[_0x54c0('0x9')](_0x54c0('0xa'),_0x4bec90,'request\x20sent');logger[_0x54c0('0xb')](_0x54c0('0xc'),_0x4bec90,'request\x20sent',JSON[_0x54c0('0xd')](_0x169411));if(_0x169411[_0x54c0('0xe')]){if(_0x169411[_0x54c0('0xe')]['code']===0x1f4){logger['error']('Automation,\x20%s,\x20%s',_0x4bec90,_0x169411[_0x54c0('0xe')][_0x54c0('0xf')]);return _0x27b874(_0x169411[_0x54c0('0xe')][_0x54c0('0xf')]);}logger['error'](_0x54c0('0xa'),_0x4bec90,_0x169411[_0x54c0('0xe')]['message']);return _0x66cd15(_0x169411[_0x54c0('0xe')]['message']);}else{logger['info'](_0x54c0('0xa'),_0x4bec90,_0x54c0('0x10'));_0x66cd15(_0x169411[_0x54c0('0x11')][_0x54c0('0xf')]);}})[_0x54c0('0x12')](function(_0x36ab0f){logger[_0x54c0('0xe')](_0x54c0('0xa'),_0x4bec90,_0x36ab0f);_0x27b874(_0x36ab0f);});});}