72bb6c76dee7ccc3506308ee83a156d64b9e48da
[motion2.git] / server / api / chatApplication / chatApplication.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 _0x8456=['code','message','lodash','util','bluebird','randomstring','../../config/utils','jayson/promise','client','request','then','info','ChatApplication,\x20%s,\x20%s','request\x20sent','ChatApplication,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x19db9b,_0x4e3b99){var _0x257ad3=function(_0x427fd3){while(--_0x427fd3){_0x19db9b['push'](_0x19db9b['shift']());}};_0x257ad3(++_0x4e3b99);}(_0x8456,0xf0));var _0x6845=function(_0x12e6b2,_0x183b5e){_0x12e6b2=_0x12e6b2-0x0;var _0x5618b2=_0x8456[_0x12e6b2];return _0x5618b2;};'use strict';var _=require(_0x6845('0x0'));var util=require(_0x6845('0x1'));var moment=require('moment');var BPromise=require(_0x6845('0x2'));var rs=require(_0x6845('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x6845('0x4'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x6845('0x5'));var client=jayson[_0x6845('0x6')]['http']({'port':0x232a});function respondWithRpcPromise(_0x108235,_0x8824d3,_0x342b40){return new BPromise(function(_0x20e5df,_0x69a43d){return client[_0x6845('0x7')](_0x108235,_0x342b40)[_0x6845('0x8')](function(_0x34699b){logger[_0x6845('0x9')](_0x6845('0xa'),_0x8824d3,_0x6845('0xb'));logger['debug'](_0x6845('0xc'),_0x8824d3,_0x6845('0xb'),JSON[_0x6845('0xd')](_0x34699b));if(_0x34699b[_0x6845('0xe')]){if(_0x34699b[_0x6845('0xe')][_0x6845('0xf')]===0x1f4){logger['error'](_0x6845('0xa'),_0x8824d3,_0x34699b['error'][_0x6845('0x10')]);return _0x69a43d(_0x34699b[_0x6845('0xe')]['message']);}logger[_0x6845('0xe')](_0x6845('0xa'),_0x8824d3,_0x34699b[_0x6845('0xe')]['message']);return _0x20e5df(_0x34699b['error'][_0x6845('0x10')]);}else{logger[_0x6845('0x9')](_0x6845('0xa'),_0x8824d3,_0x6845('0xb'));_0x20e5df(_0x34699b['result'][_0x6845('0x10')]);}})['catch'](function(_0x24fd15){logger['error'](_0x6845('0xa'),_0x8824d3,_0x24fd15);_0x69a43d(_0x24fd15);});});}