23bc973e0a3c273b3d6df529672a7730f7559407
[motion2.git] / server / api / chatGroup / chatGroup.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 _0xfbf0=['ChatGroup,\x20%s,\x20%s','request\x20sent','ChatGroup,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','util','moment','ioredis','../../mysqldb','../../config/logger','../../config/environment','client','http','defaults','redis','localhost','socket.io-emitter','./chatGroup.socket','register','info'];(function(_0x124e19,_0xe1a798){var _0x50ef96=function(_0x4faeeb){while(--_0x4faeeb){_0x124e19['push'](_0x124e19['shift']());}};_0x50ef96(++_0xe1a798);}(_0xfbf0,0x141));var _0x0fbf=function(_0x1992f1,_0x5c61f0){_0x1992f1=_0x1992f1-0x0;var _0x413dfe=_0xfbf0[_0x1992f1];return _0x413dfe;};'use strict';var _=require('lodash');var util=require(_0x0fbf('0x0'));var moment=require(_0x0fbf('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0fbf('0x2'));var db=require(_0x0fbf('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x0fbf('0x4'))('rpc');var config=require(_0x0fbf('0x5'));var jayson=require('jayson/promise');var client=jayson[_0x0fbf('0x6')][_0x0fbf('0x7')]({'port':0x232a});config['redis']=_[_0x0fbf('0x8')](config[_0x0fbf('0x9')],{'host':_0x0fbf('0xa'),'port':0x18eb});var socket=require(_0x0fbf('0xb'))(new Redis(config[_0x0fbf('0x9')]));require(_0x0fbf('0xc'))[_0x0fbf('0xd')](socket);function respondWithRpcPromise(_0x409b04,_0x165eec,_0x174e66){return new BPromise(function(_0x4d1f16,_0x3b2a6a){return client['request'](_0x409b04,_0x174e66)['then'](function(_0x45e96e){logger[_0x0fbf('0xe')](_0x0fbf('0xf'),_0x165eec,_0x0fbf('0x10'));logger['debug'](_0x0fbf('0x11'),_0x165eec,_0x0fbf('0x10'),JSON[_0x0fbf('0x12')](_0x45e96e));if(_0x45e96e[_0x0fbf('0x13')]){if(_0x45e96e[_0x0fbf('0x13')][_0x0fbf('0x14')]===0x1f4){logger[_0x0fbf('0x13')](_0x0fbf('0xf'),_0x165eec,_0x45e96e[_0x0fbf('0x13')][_0x0fbf('0x15')]);return _0x3b2a6a(_0x45e96e[_0x0fbf('0x13')][_0x0fbf('0x15')]);}logger[_0x0fbf('0x13')](_0x0fbf('0xf'),_0x165eec,_0x45e96e[_0x0fbf('0x13')][_0x0fbf('0x15')]);return _0x4d1f16(_0x45e96e[_0x0fbf('0x13')][_0x0fbf('0x15')]);}else{logger['info']('ChatGroup,\x20%s,\x20%s',_0x165eec,'request\x20sent');_0x4d1f16(_0x45e96e[_0x0fbf('0x16')][_0x0fbf('0x15')]);}})[_0x0fbf('0x17')](function(_0x296602){logger[_0x0fbf('0x13')](_0x0fbf('0xf'),_0x165eec,_0x296602);_0x3b2a6a(_0x296602);});});}