30abdd23da60caf92c39b0b200fd8ae22218287c
[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 _0xe2cf=['bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','request','then','Automation,\x20%s,\x20%s','request\x20sent','Automation,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','util'];(function(_0x50c03b,_0x21a32f){var _0x4e03a8=function(_0x6deeb){while(--_0x6deeb){_0x50c03b['push'](_0x50c03b['shift']());}};_0x4e03a8(++_0x21a32f);}(_0xe2cf,0x1a1));var _0xfe2c=function(_0x27fa56,_0x4def9b){_0x27fa56=_0x27fa56-0x0;var _0x25b2bc=_0xe2cf[_0x27fa56];return _0x25b2bc;};'use strict';var _=require('lodash');var util=require(_0xfe2c('0x0'));var moment=require('moment');var BPromise=require(_0xfe2c('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xfe2c('0x2'));var db=require(_0xfe2c('0x3'))['db'];var utils=require(_0xfe2c('0x4'));var logger=require(_0xfe2c('0x5'))('rpc');var config=require(_0xfe2c('0x6'));var jayson=require(_0xfe2c('0x7'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x4e0b97,_0x417bc4,_0x5e5b46){return new BPromise(function(_0x485a24,_0x30aafe){return client[_0xfe2c('0x8')](_0x4e0b97,_0x5e5b46)[_0xfe2c('0x9')](function(_0x562414){logger['info'](_0xfe2c('0xa'),_0x417bc4,_0xfe2c('0xb'));logger['debug'](_0xfe2c('0xc'),_0x417bc4,_0xfe2c('0xb'),JSON[_0xfe2c('0xd')](_0x562414));if(_0x562414[_0xfe2c('0xe')]){if(_0x562414[_0xfe2c('0xe')][_0xfe2c('0xf')]===0x1f4){logger[_0xfe2c('0xe')]('Automation,\x20%s,\x20%s',_0x417bc4,_0x562414['error']['message']);return _0x30aafe(_0x562414['error'][_0xfe2c('0x10')]);}logger['error']('Automation,\x20%s,\x20%s',_0x417bc4,_0x562414[_0xfe2c('0xe')][_0xfe2c('0x10')]);return _0x485a24(_0x562414[_0xfe2c('0xe')][_0xfe2c('0x10')]);}else{logger['info']('Automation,\x20%s,\x20%s',_0x417bc4,_0xfe2c('0xb'));_0x485a24(_0x562414[_0xfe2c('0x11')][_0xfe2c('0x10')]);}})[_0xfe2c('0x12')](function(_0x565f40){logger[_0xfe2c('0xe')](_0xfe2c('0xa'),_0x417bc4,_0x565f40);_0x30aafe(_0x565f40);});});}