0446b7204fa91b309f2e9940ab10a49bfd78f382
[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 _0x383a=['debug','ChatGroup,\x20%s,\x20%s,\x20%s','error','code','ChatGroup,\x20%s,\x20%s','message','info','result','catch','util','moment','ioredis','../../config/utils','../../config/logger','rpc','client','http','redis','request','request\x20sent'];(function(_0x4f9704,_0x48445e){var _0x247f1b=function(_0x1010c5){while(--_0x1010c5){_0x4f9704['push'](_0x4f9704['shift']());}};_0x247f1b(++_0x48445e);}(_0x383a,0x1ad));var _0xa383=function(_0x5b8b97,_0x6b4dfa){_0x5b8b97=_0x5b8b97-0x0;var _0x1fdf84=_0x383a[_0x5b8b97];return _0x1fdf84;};'use strict';var _=require('lodash');var util=require(_0xa383('0x0'));var moment=require(_0xa383('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa383('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0xa383('0x3'));var logger=require(_0xa383('0x4'))(_0xa383('0x5'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xa383('0x6')][_0xa383('0x7')]({'port':0x232a});config[_0xa383('0x8')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xa383('0x8')]));require('./chatGroup.socket')['register'](socket);function respondWithRpcPromise(_0x1b676b,_0x3d63e4,_0x54a64c){return new BPromise(function(_0x3c0b0b,_0x98afe6){return client[_0xa383('0x9')](_0x1b676b,_0x54a64c)['then'](function(_0x2b6871){logger['info']('ChatGroup,\x20%s,\x20%s',_0x3d63e4,_0xa383('0xa'));logger[_0xa383('0xb')](_0xa383('0xc'),_0x3d63e4,_0xa383('0xa'),JSON['stringify'](_0x2b6871));if(_0x2b6871[_0xa383('0xd')]){if(_0x2b6871[_0xa383('0xd')][_0xa383('0xe')]===0x1f4){logger[_0xa383('0xd')](_0xa383('0xf'),_0x3d63e4,_0x2b6871[_0xa383('0xd')][_0xa383('0x10')]);return _0x98afe6(_0x2b6871[_0xa383('0xd')]['message']);}logger['error'](_0xa383('0xf'),_0x3d63e4,_0x2b6871[_0xa383('0xd')][_0xa383('0x10')]);return _0x3c0b0b(_0x2b6871[_0xa383('0xd')]['message']);}else{logger[_0xa383('0x11')]('ChatGroup,\x20%s,\x20%s',_0x3d63e4,_0xa383('0xa'));_0x3c0b0b(_0x2b6871[_0xa383('0x12')][_0xa383('0x10')]);}})[_0xa383('0x13')](function(_0x1e0b81){logger[_0xa383('0xd')](_0xa383('0xf'),_0x3d63e4,_0x1e0b81);_0x98afe6(_0x1e0b81);});});}