d80a29e3515dcb1e9154752c069fa970e2a4f7db
[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 _0xd730=['Automation,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','util','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','then','info','Automation,\x20%s,\x20%s','request\x20sent'];(function(_0x2ed8f3,_0x4aa12f){var _0x525a55=function(_0x4cfb58){while(--_0x4cfb58){_0x2ed8f3['push'](_0x2ed8f3['shift']());}};_0x525a55(++_0x4aa12f);}(_0xd730,0xfd));var _0x0d73=function(_0x46379f,_0x5764bc){_0x46379f=_0x46379f-0x0;var _0x41a7f0=_0xd730[_0x46379f];return _0x41a7f0;};'use strict';var _=require('lodash');var util=require(_0x0d73('0x0'));var moment=require('moment');var BPromise=require(_0x0d73('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0d73('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0x0d73('0x3'));var logger=require(_0x0d73('0x4'))(_0x0d73('0x5'));var config=require(_0x0d73('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x0d73('0x7')][_0x0d73('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x55aba2,_0x1dc342,_0x5b966e){return new BPromise(function(_0x2a7202,_0x4a39f0){return client['request'](_0x55aba2,_0x5b966e)[_0x0d73('0x9')](function(_0x5792d1){logger[_0x0d73('0xa')](_0x0d73('0xb'),_0x1dc342,_0x0d73('0xc'));logger['debug'](_0x0d73('0xd'),_0x1dc342,'request\x20sent',JSON[_0x0d73('0xe')](_0x5792d1));if(_0x5792d1[_0x0d73('0xf')]){if(_0x5792d1[_0x0d73('0xf')][_0x0d73('0x10')]===0x1f4){logger[_0x0d73('0xf')](_0x0d73('0xb'),_0x1dc342,_0x5792d1[_0x0d73('0xf')][_0x0d73('0x11')]);return _0x4a39f0(_0x5792d1[_0x0d73('0xf')][_0x0d73('0x11')]);}logger[_0x0d73('0xf')](_0x0d73('0xb'),_0x1dc342,_0x5792d1[_0x0d73('0xf')]['message']);return _0x2a7202(_0x5792d1[_0x0d73('0xf')][_0x0d73('0x11')]);}else{logger[_0x0d73('0xa')](_0x0d73('0xb'),_0x1dc342,_0x0d73('0xc'));_0x2a7202(_0x5792d1['result'][_0x0d73('0x11')]);}})[_0x0d73('0x12')](function(_0x515c9a){logger['error']('Automation,\x20%s,\x20%s',_0x1dc342,_0x515c9a);_0x4a39f0(_0x515c9a);});});}