Built motion from commit efa66e19.|2.6.22
[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 _0xdcb6=['client','http','request','Condition,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','Condition,\x20%s,\x20%s','message','info','catch','util','bluebird','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x118305,_0x1f0f7e){var _0x4f2e28=function(_0xbaff78){while(--_0xbaff78){_0x118305['push'](_0x118305['shift']());}};_0x4f2e28(++_0x1f0f7e);}(_0xdcb6,0x1a3));var _0x6dcb=function(_0x15bc81,_0x4d4f77){_0x15bc81=_0x15bc81-0x0;var _0x59440e=_0xdcb6[_0x15bc81];return _0x59440e;};'use strict';var _=require('lodash');var util=require(_0x6dcb('0x0'));var moment=require('moment');var BPromise=require(_0x6dcb('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x6dcb('0x2'));var logger=require(_0x6dcb('0x3'))(_0x6dcb('0x4'));var config=require(_0x6dcb('0x5'));var jayson=require('jayson/promise');var client=jayson[_0x6dcb('0x6')][_0x6dcb('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x3d25d2,_0x4c674f,_0x13f9f9){return new BPromise(function(_0x4b3de7,_0x101bf1){return client[_0x6dcb('0x8')](_0x3d25d2,_0x13f9f9)['then'](function(_0x4375b5){logger['info']('Condition,\x20%s,\x20%s',_0x4c674f,'request\x20sent');logger['debug'](_0x6dcb('0x9'),_0x4c674f,_0x6dcb('0xa'),JSON['stringify'](_0x4375b5));if(_0x4375b5[_0x6dcb('0xb')]){if(_0x4375b5[_0x6dcb('0xb')][_0x6dcb('0xc')]===0x1f4){logger['error'](_0x6dcb('0xd'),_0x4c674f,_0x4375b5[_0x6dcb('0xb')][_0x6dcb('0xe')]);return _0x101bf1(_0x4375b5[_0x6dcb('0xb')][_0x6dcb('0xe')]);}logger[_0x6dcb('0xb')](_0x6dcb('0xd'),_0x4c674f,_0x4375b5[_0x6dcb('0xb')][_0x6dcb('0xe')]);return _0x4b3de7(_0x4375b5[_0x6dcb('0xb')]['message']);}else{logger[_0x6dcb('0xf')]('Condition,\x20%s,\x20%s',_0x4c674f,'request\x20sent');_0x4b3de7(_0x4375b5['result']['message']);}})[_0x6dcb('0x10')](function(_0x428445){logger['error']('Condition,\x20%s,\x20%s',_0x4c674f,_0x428445);_0x101bf1(_0x428445);});});}