b2fac144751732fcbc16aaae55a3640686efd8f2
[motion2.git] / server / api / team / team.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 _0x25a8=['Team,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','catch','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','./team.socket','register','then','info'];(function(_0x53c1ad,_0x112aad){var _0x34e090=function(_0x33f9d9){while(--_0x33f9d9){_0x53c1ad['push'](_0x53c1ad['shift']());}};_0x34e090(++_0x112aad);}(_0x25a8,0x8f));var _0x825a=function(_0x4c29d5,_0x314502){_0x4c29d5=_0x4c29d5-0x0;var _0x2ef6ed=_0x25a8[_0x4c29d5];return _0x2ef6ed;};'use strict';var _=require(_0x825a('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x825a('0x1'));var rs=require(_0x825a('0x2'));var fs=require('fs');var Redis=require(_0x825a('0x3'));var db=require(_0x825a('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x825a('0x5'))(_0x825a('0x6'));var config=require(_0x825a('0x7'));var jayson=require(_0x825a('0x8'));var client=jayson[_0x825a('0x9')][_0x825a('0xa')]({'port':0x232a});config['redis']=_[_0x825a('0xb')](config[_0x825a('0xc')],{'host':_0x825a('0xd'),'port':0x18eb});var socket=require(_0x825a('0xe'))(new Redis(config[_0x825a('0xc')]));require(_0x825a('0xf'))[_0x825a('0x10')](socket);function respondWithRpcPromise(_0x10cdb5,_0x40cb8b,_0x130176){return new BPromise(function(_0x1d58d2,_0x2be610){return client['request'](_0x10cdb5,_0x130176)[_0x825a('0x11')](function(_0x252ac2){logger[_0x825a('0x12')](_0x825a('0x13'),_0x40cb8b,_0x825a('0x14'));logger[_0x825a('0x15')]('Team,\x20%s,\x20%s,\x20%s',_0x40cb8b,'request\x20sent',JSON[_0x825a('0x16')](_0x252ac2));if(_0x252ac2[_0x825a('0x17')]){if(_0x252ac2[_0x825a('0x17')]['code']===0x1f4){logger['error']('Team,\x20%s,\x20%s',_0x40cb8b,_0x252ac2['error'][_0x825a('0x18')]);return _0x2be610(_0x252ac2[_0x825a('0x17')]['message']);}logger['error'](_0x825a('0x13'),_0x40cb8b,_0x252ac2[_0x825a('0x17')][_0x825a('0x18')]);return _0x1d58d2(_0x252ac2[_0x825a('0x17')][_0x825a('0x18')]);}else{logger[_0x825a('0x12')]('Team,\x20%s,\x20%s',_0x40cb8b,'request\x20sent');_0x1d58d2(_0x252ac2[_0x825a('0x19')]['message']);}})[_0x825a('0x1a')](function(_0x3633cc){logger['error'](_0x825a('0x13'),_0x40cb8b,_0x3633cc);_0x2be610(_0x3633cc);});});}