Built motion from commit (unavailable).|2.5.18
[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 _0x13f6=['Automation,\x20%s,\x20%s,\x20%s','error','code','message','result','util','bluebird','randomstring','../../config/utils','../../config/logger','client','http','request','info','Automation,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x41ce2f,_0x5a01e7){var _0xdefc5c=function(_0x3529eb){while(--_0x3529eb){_0x41ce2f['push'](_0x41ce2f['shift']());}};_0xdefc5c(++_0x5a01e7);}(_0x13f6,0xaf));var _0x613f=function(_0x5f2846,_0x4c43e0){_0x5f2846=_0x5f2846-0x0;var _0x190f3e=_0x13f6[_0x5f2846];return _0x190f3e;};'use strict';var _=require('lodash');var util=require(_0x613f('0x0'));var moment=require('moment');var BPromise=require(_0x613f('0x1'));var rs=require(_0x613f('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x613f('0x3'));var logger=require(_0x613f('0x4'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x613f('0x5')][_0x613f('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x491cde,_0x51a459,_0x1ca493){return new BPromise(function(_0x5e1811,_0x1f81a8){return client[_0x613f('0x7')](_0x491cde,_0x1ca493)['then'](function(_0x13988b){logger[_0x613f('0x8')](_0x613f('0x9'),_0x51a459,_0x613f('0xa'));logger[_0x613f('0xb')](_0x613f('0xc'),_0x51a459,'request\x20sent',JSON['stringify'](_0x13988b));if(_0x13988b[_0x613f('0xd')]){if(_0x13988b[_0x613f('0xd')][_0x613f('0xe')]===0x1f4){logger[_0x613f('0xd')]('Automation,\x20%s,\x20%s',_0x51a459,_0x13988b[_0x613f('0xd')][_0x613f('0xf')]);return _0x1f81a8(_0x13988b[_0x613f('0xd')][_0x613f('0xf')]);}logger[_0x613f('0xd')](_0x613f('0x9'),_0x51a459,_0x13988b[_0x613f('0xd')]['message']);return _0x5e1811(_0x13988b[_0x613f('0xd')]['message']);}else{logger[_0x613f('0x8')](_0x613f('0x9'),_0x51a459,_0x613f('0xa'));_0x5e1811(_0x13988b[_0x613f('0x10')][_0x613f('0xf')]);}})['catch'](function(_0x1de5b1){logger[_0x613f('0xd')]('Automation,\x20%s,\x20%s',_0x51a459,_0x1de5b1);_0x1f81a8(_0x1de5b1);});});}