Built motion from commit 616d3211.|2.6.4
[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 _0x288a=['jayson/promise','http','request','then','info','Automation,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','util','moment','bluebird','randomstring','../../config/utils','rpc','../../config/environment'];(function(_0x17c90f,_0x43864d){var _0x5df760=function(_0x1ef7e7){while(--_0x1ef7e7){_0x17c90f['push'](_0x17c90f['shift']());}};_0x5df760(++_0x43864d);}(_0x288a,0x188));var _0xa288=function(_0x1549ce,_0x1c2651){_0x1549ce=_0x1549ce-0x0;var _0x1f7881=_0x288a[_0x1549ce];return _0x1f7881;};'use strict';var _=require('lodash');var util=require(_0xa288('0x0'));var moment=require(_0xa288('0x1'));var BPromise=require(_0xa288('0x2'));var rs=require(_0xa288('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xa288('0x4'));var logger=require('../../config/logger')(_0xa288('0x5'));var config=require(_0xa288('0x6'));var jayson=require(_0xa288('0x7'));var client=jayson['client'][_0xa288('0x8')]({'port':0x232a});function respondWithRpcPromise(_0xaee90c,_0x156720,_0x57f445){return new BPromise(function(_0x14e4a6,_0x1e8412){return client[_0xa288('0x9')](_0xaee90c,_0x57f445)[_0xa288('0xa')](function(_0x1a0c06){logger[_0xa288('0xb')](_0xa288('0xc'),_0x156720,_0xa288('0xd'));logger['debug']('Automation,\x20%s,\x20%s,\x20%s',_0x156720,'request\x20sent',JSON[_0xa288('0xe')](_0x1a0c06));if(_0x1a0c06[_0xa288('0xf')]){if(_0x1a0c06['error'][_0xa288('0x10')]===0x1f4){logger[_0xa288('0xf')](_0xa288('0xc'),_0x156720,_0x1a0c06[_0xa288('0xf')][_0xa288('0x11')]);return _0x1e8412(_0x1a0c06[_0xa288('0xf')][_0xa288('0x11')]);}logger[_0xa288('0xf')](_0xa288('0xc'),_0x156720,_0x1a0c06[_0xa288('0xf')][_0xa288('0x11')]);return _0x14e4a6(_0x1a0c06[_0xa288('0xf')][_0xa288('0x11')]);}else{logger[_0xa288('0xb')](_0xa288('0xc'),_0x156720,_0xa288('0xd'));_0x14e4a6(_0x1a0c06['result'][_0xa288('0x11')]);}})[_0xa288('0x12')](function(_0x299ede){logger[_0xa288('0xf')](_0xa288('0xc'),_0x156720,_0x299ede);_0x1e8412(_0x299ede);});});}