55d6c4a2c0f44fff6b3d7279d3caef7b44c2c4c3
[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 _0xe953=['result','catch','ioredis','../../mysqldb','../../config/logger','../../config/environment','client','http','redis','defaults','socket.io-emitter','./chatGroup.socket','request','info','ChatGroup,\x20%s,\x20%s','request\x20sent','debug','ChatGroup,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x41c24c,_0x5275ce){var _0xafb71a=function(_0x317294){while(--_0x317294){_0x41c24c['push'](_0x41c24c['shift']());}};_0xafb71a(++_0x5275ce);}(_0xe953,0x1d0));var _0x3e95=function(_0x19dd7a,_0x51de21){_0x19dd7a=_0x19dd7a-0x0;var _0x3feb6a=_0xe953[_0x19dd7a];return _0x3feb6a;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x3e95('0x0'));var db=require(_0x3e95('0x1'))['db'];var utils=require('../../config/utils');var logger=require(_0x3e95('0x2'))('rpc');var config=require(_0x3e95('0x3'));var jayson=require('jayson/promise');var client=jayson[_0x3e95('0x4')][_0x3e95('0x5')]({'port':0x232a});config[_0x3e95('0x6')]=_[_0x3e95('0x7')](config[_0x3e95('0x6')],{'host':'localhost','port':0x18eb});var socket=require(_0x3e95('0x8'))(new Redis(config[_0x3e95('0x6')]));require(_0x3e95('0x9'))['register'](socket);function respondWithRpcPromise(_0xf019c5,_0x12a756,_0x35ed18){return new BPromise(function(_0x459b58,_0x57c602){return client[_0x3e95('0xa')](_0xf019c5,_0x35ed18)['then'](function(_0x4719dc){logger[_0x3e95('0xb')](_0x3e95('0xc'),_0x12a756,_0x3e95('0xd'));logger[_0x3e95('0xe')](_0x3e95('0xf'),_0x12a756,'request\x20sent',JSON[_0x3e95('0x10')](_0x4719dc));if(_0x4719dc[_0x3e95('0x11')]){if(_0x4719dc['error'][_0x3e95('0x12')]===0x1f4){logger[_0x3e95('0x11')](_0x3e95('0xc'),_0x12a756,_0x4719dc[_0x3e95('0x11')]['message']);return _0x57c602(_0x4719dc[_0x3e95('0x11')][_0x3e95('0x13')]);}logger['error'](_0x3e95('0xc'),_0x12a756,_0x4719dc[_0x3e95('0x11')][_0x3e95('0x13')]);return _0x459b58(_0x4719dc[_0x3e95('0x11')]['message']);}else{logger[_0x3e95('0xb')]('ChatGroup,\x20%s,\x20%s',_0x12a756,_0x3e95('0xd'));_0x459b58(_0x4719dc[_0x3e95('0x14')]['message']);}})[_0x3e95('0x15')](function(_0x3e8b32){logger[_0x3e95('0x11')](_0x3e95('0xc'),_0x12a756,_0x3e8b32);_0x57c602(_0x3e8b32);});});}