a64df5f17aa5df25c8dcef32e42d3e7aea0579f0
[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 _0x1d93=['code','message','result','util','moment','bluebird','ioredis','../../config/logger','rpc','jayson/promise','localhost','redis','./chatGroup.socket','register','info','ChatGroup,\x20%s,\x20%s','request\x20sent','debug','ChatGroup,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x1999e6,_0x5a31c2){var _0x3ecae5=function(_0x5cf8ae){while(--_0x5cf8ae){_0x1999e6['push'](_0x1999e6['shift']());}};_0x3ecae5(++_0x5a31c2);}(_0x1d93,0x1bc));var _0x31d9=function(_0x19a4ae,_0x21054a){_0x19a4ae=_0x19a4ae-0x0;var _0x13b6c3=_0x1d93[_0x19a4ae];return _0x13b6c3;};'use strict';var _=require('lodash');var util=require(_0x31d9('0x0'));var moment=require(_0x31d9('0x1'));var BPromise=require(_0x31d9('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x31d9('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x31d9('0x4'))(_0x31d9('0x5'));var config=require('../../config/environment');var jayson=require(_0x31d9('0x6'));var client=jayson['client']['http']({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':_0x31d9('0x7'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x31d9('0x8')]));require(_0x31d9('0x9'))[_0x31d9('0xa')](socket);function respondWithRpcPromise(_0x159078,_0x374a7c,_0x15d57c){return new BPromise(function(_0x42cb2c,_0x23a75f){return client['request'](_0x159078,_0x15d57c)['then'](function(_0x89f559){logger[_0x31d9('0xb')](_0x31d9('0xc'),_0x374a7c,_0x31d9('0xd'));logger[_0x31d9('0xe')](_0x31d9('0xf'),_0x374a7c,_0x31d9('0xd'),JSON[_0x31d9('0x10')](_0x89f559));if(_0x89f559[_0x31d9('0x11')]){if(_0x89f559[_0x31d9('0x11')][_0x31d9('0x12')]===0x1f4){logger[_0x31d9('0x11')](_0x31d9('0xc'),_0x374a7c,_0x89f559['error'][_0x31d9('0x13')]);return _0x23a75f(_0x89f559[_0x31d9('0x11')][_0x31d9('0x13')]);}logger['error'](_0x31d9('0xc'),_0x374a7c,_0x89f559[_0x31d9('0x11')]['message']);return _0x42cb2c(_0x89f559[_0x31d9('0x11')]['message']);}else{logger[_0x31d9('0xb')](_0x31d9('0xc'),_0x374a7c,_0x31d9('0xd'));_0x42cb2c(_0x89f559[_0x31d9('0x14')][_0x31d9('0x13')]);}})['catch'](function(_0x45272a){logger[_0x31d9('0x11')](_0x31d9('0xc'),_0x374a7c,_0x45272a);_0x23a75f(_0x45272a);});});}