3805915cbaff61841c1aae1daf15e5084c05c47f
[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 _0x585e=['then','info','request\x20sent','debug','error','code','message','Automation,\x20%s,\x20%s','result','lodash','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request'];(function(_0x32725d,_0x3e1456){var _0x5bc194=function(_0x541089){while(--_0x541089){_0x32725d['push'](_0x32725d['shift']());}};_0x5bc194(++_0x3e1456);}(_0x585e,0x1c2));var _0xe585=function(_0x45d4b2,_0x58938a){_0x45d4b2=_0x45d4b2-0x0;var _0x122f4b=_0x585e[_0x45d4b2];return _0x122f4b;};'use strict';var _=require(_0xe585('0x0'));var util=require(_0xe585('0x1'));var moment=require(_0xe585('0x2'));var BPromise=require(_0xe585('0x3'));var rs=require(_0xe585('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xe585('0x5'));var logger=require(_0xe585('0x6'))('rpc');var config=require(_0xe585('0x7'));var jayson=require(_0xe585('0x8'));var client=jayson[_0xe585('0x9')][_0xe585('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x13a862,_0x50a2b2,_0x46642c){return new BPromise(function(_0x19d1ec,_0x204326){return client[_0xe585('0xb')](_0x13a862,_0x46642c)[_0xe585('0xc')](function(_0x20b3b9){logger[_0xe585('0xd')]('Automation,\x20%s,\x20%s',_0x50a2b2,_0xe585('0xe'));logger[_0xe585('0xf')]('Automation,\x20%s,\x20%s,\x20%s',_0x50a2b2,_0xe585('0xe'),JSON['stringify'](_0x20b3b9));if(_0x20b3b9[_0xe585('0x10')]){if(_0x20b3b9[_0xe585('0x10')][_0xe585('0x11')]===0x1f4){logger[_0xe585('0x10')]('Automation,\x20%s,\x20%s',_0x50a2b2,_0x20b3b9[_0xe585('0x10')][_0xe585('0x12')]);return _0x204326(_0x20b3b9[_0xe585('0x10')]['message']);}logger[_0xe585('0x10')](_0xe585('0x13'),_0x50a2b2,_0x20b3b9[_0xe585('0x10')][_0xe585('0x12')]);return _0x19d1ec(_0x20b3b9[_0xe585('0x10')]['message']);}else{logger[_0xe585('0xd')]('Automation,\x20%s,\x20%s',_0x50a2b2,'request\x20sent');_0x19d1ec(_0x20b3b9[_0xe585('0x14')][_0xe585('0x12')]);}})['catch'](function(_0x1ced58){logger[_0xe585('0x10')]('Automation,\x20%s,\x20%s',_0x50a2b2,_0x1ced58);_0x204326(_0x1ced58);});});}