0405cef1af986d57d3f9eccd62154609197fd223
[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 _0xc11f=['randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','request','request\x20sent','debug','stringify','error','code','Automation,\x20%s,\x20%s','message','result','catch','lodash','moment','bluebird'];(function(_0x560f7d,_0x4b8cf1){var _0x14721a=function(_0x320588){while(--_0x320588){_0x560f7d['push'](_0x560f7d['shift']());}};_0x14721a(++_0x4b8cf1);}(_0xc11f,0x1b5));var _0xfc11=function(_0x1241ad,_0x9e332a){_0x1241ad=_0x1241ad-0x0;var _0x49b9e1=_0xc11f[_0x1241ad];return _0x49b9e1;};'use strict';var _=require(_0xfc11('0x0'));var util=require('util');var moment=require(_0xfc11('0x1'));var BPromise=require(_0xfc11('0x2'));var rs=require(_0xfc11('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xfc11('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xfc11('0x5'))(_0xfc11('0x6'));var config=require(_0xfc11('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xfc11('0x8')][_0xfc11('0x9')]({'port':0x232a});function respondWithRpcPromise(_0xcabf9f,_0x1aa1a2,_0x2d7f15){return new BPromise(function(_0x57a481,_0x151f5f){return client[_0xfc11('0xa')](_0xcabf9f,_0x2d7f15)['then'](function(_0x60f1ed){logger['info']('Automation,\x20%s,\x20%s',_0x1aa1a2,_0xfc11('0xb'));logger[_0xfc11('0xc')]('Automation,\x20%s,\x20%s,\x20%s',_0x1aa1a2,'request\x20sent',JSON[_0xfc11('0xd')](_0x60f1ed));if(_0x60f1ed[_0xfc11('0xe')]){if(_0x60f1ed[_0xfc11('0xe')][_0xfc11('0xf')]===0x1f4){logger['error'](_0xfc11('0x10'),_0x1aa1a2,_0x60f1ed['error'][_0xfc11('0x11')]);return _0x151f5f(_0x60f1ed[_0xfc11('0xe')][_0xfc11('0x11')]);}logger[_0xfc11('0xe')](_0xfc11('0x10'),_0x1aa1a2,_0x60f1ed[_0xfc11('0xe')][_0xfc11('0x11')]);return _0x57a481(_0x60f1ed[_0xfc11('0xe')]['message']);}else{logger['info'](_0xfc11('0x10'),_0x1aa1a2,_0xfc11('0xb'));_0x57a481(_0x60f1ed[_0xfc11('0x12')][_0xfc11('0x11')]);}})[_0xfc11('0x13')](function(_0x26623e){logger[_0xfc11('0xe')]('Automation,\x20%s,\x20%s',_0x1aa1a2,_0x26623e);_0x151f5f(_0x26623e);});});}