0cd857c177c761c6039f6055912843c2f6a40df6
[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 _0x998f=['ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','request','info','ChatApplication,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','lodash','util','randomstring'];(function(_0x18b344,_0x271f68){var _0x5ef6bb=function(_0x3345b3){while(--_0x3345b3){_0x18b344['push'](_0x18b344['shift']());}};_0x5ef6bb(++_0x271f68);}(_0x998f,0x89));var _0xf998=function(_0x2b068e,_0x59da22){_0x2b068e=_0x2b068e-0x0;var _0x4bed64=_0x998f[_0x2b068e];return _0x4bed64;};'use strict';var _=require(_0xf998('0x0'));var util=require(_0xf998('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xf998('0x2'));var fs=require('fs');var Redis=require(_0xf998('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xf998('0x4'));var logger=require(_0xf998('0x5'))('rpc');var config=require(_0xf998('0x6'));var jayson=require(_0xf998('0x7'));var client=jayson['client'][_0xf998('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x4d14ca,_0x22c554,_0x2016ff){return new BPromise(function(_0x2b82ea,_0x2d9edf){return client[_0xf998('0x9')](_0x4d14ca,_0x2016ff)['then'](function(_0x40c918){logger[_0xf998('0xa')](_0xf998('0xb'),_0x22c554,_0xf998('0xc'));logger[_0xf998('0xd')]('ChatApplication,\x20%s,\x20%s,\x20%s',_0x22c554,'request\x20sent',JSON[_0xf998('0xe')](_0x40c918));if(_0x40c918['error']){if(_0x40c918[_0xf998('0xf')][_0xf998('0x10')]===0x1f4){logger['error']('ChatApplication,\x20%s,\x20%s',_0x22c554,_0x40c918['error']['message']);return _0x2d9edf(_0x40c918[_0xf998('0xf')]['message']);}logger[_0xf998('0xf')]('ChatApplication,\x20%s,\x20%s',_0x22c554,_0x40c918['error']['message']);return _0x2b82ea(_0x40c918[_0xf998('0xf')][_0xf998('0x11')]);}else{logger['info'](_0xf998('0xb'),_0x22c554,'request\x20sent');_0x2b82ea(_0x40c918[_0xf998('0x12')]['message']);}})[_0xf998('0x13')](function(_0x273bd6){logger[_0xf998('0xf')](_0xf998('0xb'),_0x22c554,_0x273bd6);_0x2d9edf(_0x273bd6);});});}