5311deec516280d905754285b17b2b150a5f3f3b
[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 _0x4cf2=['moment','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','defaults','redis','socket.io-emitter','./team.socket','register','then','info','request\x20sent','Team,\x20%s,\x20%s,\x20%s','stringify','error','Team,\x20%s,\x20%s','message','result','util'];(function(_0x1a712b,_0x203f10){var _0x6fdd88=function(_0x483bc9){while(--_0x483bc9){_0x1a712b['push'](_0x1a712b['shift']());}};_0x6fdd88(++_0x203f10);}(_0x4cf2,0xf1));var _0x24cf=function(_0x5ed54b,_0x3a2827){_0x5ed54b=_0x5ed54b-0x0;var _0x4b58c7=_0x4cf2[_0x5ed54b];return _0x4b58c7;};'use strict';var _=require('lodash');var util=require(_0x24cf('0x0'));var moment=require(_0x24cf('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x24cf('0x2'))['db'];var utils=require(_0x24cf('0x3'));var logger=require(_0x24cf('0x4'))(_0x24cf('0x5'));var config=require(_0x24cf('0x6'));var jayson=require(_0x24cf('0x7'));var client=jayson['client']['http']({'port':0x232a});config['redis']=_[_0x24cf('0x8')](config[_0x24cf('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0x24cf('0xa'))(new Redis(config['redis']));require(_0x24cf('0xb'))[_0x24cf('0xc')](socket);function respondWithRpcPromise(_0x1e8fa0,_0x379100,_0x252e9b){return new BPromise(function(_0x2ed1d4,_0x498ea9){return client['request'](_0x1e8fa0,_0x252e9b)[_0x24cf('0xd')](function(_0x3cc3c2){logger[_0x24cf('0xe')]('Team,\x20%s,\x20%s',_0x379100,_0x24cf('0xf'));logger['debug'](_0x24cf('0x10'),_0x379100,_0x24cf('0xf'),JSON[_0x24cf('0x11')](_0x3cc3c2));if(_0x3cc3c2[_0x24cf('0x12')]){if(_0x3cc3c2[_0x24cf('0x12')]['code']===0x1f4){logger['error'](_0x24cf('0x13'),_0x379100,_0x3cc3c2[_0x24cf('0x12')][_0x24cf('0x14')]);return _0x498ea9(_0x3cc3c2['error'][_0x24cf('0x14')]);}logger[_0x24cf('0x12')](_0x24cf('0x13'),_0x379100,_0x3cc3c2['error']['message']);return _0x2ed1d4(_0x3cc3c2[_0x24cf('0x12')][_0x24cf('0x14')]);}else{logger[_0x24cf('0xe')]('Team,\x20%s,\x20%s',_0x379100,_0x24cf('0xf'));_0x2ed1d4(_0x3cc3c2[_0x24cf('0x15')][_0x24cf('0x14')]);}})['catch'](function(_0xce55e1){logger['error'](_0x24cf('0x13'),_0x379100,_0xce55e1);_0x498ea9(_0xce55e1);});});}