38a4cdbeededa49c342e7505b156407484ba7060
[motion2.git] / server / api / condition / condition.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 _0x9a62=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','request','info','Condition,\x20%s,\x20%s','request\x20sent','debug','Condition,\x20%s,\x20%s,\x20%s','error','message','catch','lodash','moment'];(function(_0x4aac5a,_0x15b04c){var _0x42e7bc=function(_0x1da766){while(--_0x1da766){_0x4aac5a['push'](_0x4aac5a['shift']());}};_0x42e7bc(++_0x15b04c);}(_0x9a62,0x9e));var _0x29a6=function(_0x57b54c,_0x54ce0d){_0x57b54c=_0x57b54c-0x0;var _0x59cc19=_0x9a62[_0x57b54c];return _0x59cc19;};'use strict';var _=require(_0x29a6('0x0'));var util=require('util');var moment=require(_0x29a6('0x1'));var BPromise=require(_0x29a6('0x2'));var rs=require(_0x29a6('0x3'));var fs=require('fs');var Redis=require(_0x29a6('0x4'));var db=require(_0x29a6('0x5'))['db'];var utils=require(_0x29a6('0x6'));var logger=require(_0x29a6('0x7'))(_0x29a6('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x29a6('0x9')][_0x29a6('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x5c2837,_0x457b99,_0x21c7ea){return new BPromise(function(_0x307955,_0x1ef5d7){return client[_0x29a6('0xb')](_0x5c2837,_0x21c7ea)['then'](function(_0x383b06){logger[_0x29a6('0xc')](_0x29a6('0xd'),_0x457b99,_0x29a6('0xe'));logger[_0x29a6('0xf')](_0x29a6('0x10'),_0x457b99,_0x29a6('0xe'),JSON['stringify'](_0x383b06));if(_0x383b06[_0x29a6('0x11')]){if(_0x383b06[_0x29a6('0x11')]['code']===0x1f4){logger[_0x29a6('0x11')](_0x29a6('0xd'),_0x457b99,_0x383b06[_0x29a6('0x11')]['message']);return _0x1ef5d7(_0x383b06[_0x29a6('0x11')][_0x29a6('0x12')]);}logger[_0x29a6('0x11')](_0x29a6('0xd'),_0x457b99,_0x383b06[_0x29a6('0x11')][_0x29a6('0x12')]);return _0x307955(_0x383b06[_0x29a6('0x11')]['message']);}else{logger[_0x29a6('0xc')]('Condition,\x20%s,\x20%s',_0x457b99,'request\x20sent');_0x307955(_0x383b06['result'][_0x29a6('0x12')]);}})[_0x29a6('0x13')](function(_0x582303){logger[_0x29a6('0x11')](_0x29a6('0xd'),_0x457b99,_0x582303);_0x1ef5d7(_0x582303);});});}