Built motion from commit (unavailable).|2.5.22
[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 _0xb692=['../../config/logger','../../config/environment','client','http','request','then','info','Automation,\x20%s,\x20%s','request\x20sent','debug','Automation,\x20%s,\x20%s,\x20%s','error','message','lodash','util','moment','randomstring','ioredis','../../config/utils'];(function(_0x2df387,_0x1d3ea1){var _0x3b1708=function(_0x49c05b){while(--_0x49c05b){_0x2df387['push'](_0x2df387['shift']());}};_0x3b1708(++_0x1d3ea1);}(_0xb692,0x163));var _0x2b69=function(_0xe4d35a,_0x4bd94d){_0xe4d35a=_0xe4d35a-0x0;var _0x249363=_0xb692[_0xe4d35a];return _0x249363;};'use strict';var _=require(_0x2b69('0x0'));var util=require(_0x2b69('0x1'));var moment=require(_0x2b69('0x2'));var BPromise=require('bluebird');var rs=require(_0x2b69('0x3'));var fs=require('fs');var Redis=require(_0x2b69('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x2b69('0x5'));var logger=require(_0x2b69('0x6'))('rpc');var config=require(_0x2b69('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x2b69('0x8')][_0x2b69('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5bd228,_0x56295e,_0x4169a2){return new BPromise(function(_0x43f45a,_0x31e087){return client[_0x2b69('0xa')](_0x5bd228,_0x4169a2)[_0x2b69('0xb')](function(_0x178fa2){logger[_0x2b69('0xc')](_0x2b69('0xd'),_0x56295e,_0x2b69('0xe'));logger[_0x2b69('0xf')](_0x2b69('0x10'),_0x56295e,_0x2b69('0xe'),JSON['stringify'](_0x178fa2));if(_0x178fa2[_0x2b69('0x11')]){if(_0x178fa2[_0x2b69('0x11')]['code']===0x1f4){logger[_0x2b69('0x11')](_0x2b69('0xd'),_0x56295e,_0x178fa2[_0x2b69('0x11')][_0x2b69('0x12')]);return _0x31e087(_0x178fa2['error'][_0x2b69('0x12')]);}logger[_0x2b69('0x11')]('Automation,\x20%s,\x20%s',_0x56295e,_0x178fa2[_0x2b69('0x11')][_0x2b69('0x12')]);return _0x43f45a(_0x178fa2[_0x2b69('0x11')][_0x2b69('0x12')]);}else{logger['info'](_0x2b69('0xd'),_0x56295e,_0x2b69('0xe'));_0x43f45a(_0x178fa2['result'][_0x2b69('0x12')]);}})['catch'](function(_0xfa7fd9){logger['error']('Automation,\x20%s,\x20%s',_0x56295e,_0xfa7fd9);_0x31e087(_0xfa7fd9);});});}