8095e683fea4ae3b70a39f33316cb8963e03f4f9
[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 _0xb666=['util','moment','ioredis','../../mysqldb','../../config/utils','../../config/environment','client','http','redis','defaults','localhost','./team.socket','register','request','then','info','Team,\x20%s,\x20%s','debug','stringify','error','code','message','request\x20sent','catch'];(function(_0x3344a6,_0x352564){var _0x4a5b1e=function(_0x359d4a){while(--_0x359d4a){_0x3344a6['push'](_0x3344a6['shift']());}};_0x4a5b1e(++_0x352564);}(_0xb666,0xa8));var _0x6b66=function(_0x3b5250,_0x7a0b2c){_0x3b5250=_0x3b5250-0x0;var _0xc844a1=_0xb666[_0x3b5250];return _0xc844a1;};'use strict';var _=require('lodash');var util=require(_0x6b66('0x0'));var moment=require(_0x6b66('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x6b66('0x2'));var db=require(_0x6b66('0x3'))['db'];var utils=require(_0x6b66('0x4'));var logger=require('../../config/logger')('rpc');var config=require(_0x6b66('0x5'));var jayson=require('jayson/promise');var client=jayson[_0x6b66('0x6')][_0x6b66('0x7')]({'port':0x232a});config[_0x6b66('0x8')]=_[_0x6b66('0x9')](config[_0x6b66('0x8')],{'host':_0x6b66('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x6b66('0x8')]));require(_0x6b66('0xb'))[_0x6b66('0xc')](socket);function respondWithRpcPromise(_0x2ff8d7,_0x5e497c,_0x2fc105){return new BPromise(function(_0x205a18,_0x2f5686){return client[_0x6b66('0xd')](_0x2ff8d7,_0x2fc105)[_0x6b66('0xe')](function(_0x5025c1){logger[_0x6b66('0xf')](_0x6b66('0x10'),_0x5e497c,'request\x20sent');logger[_0x6b66('0x11')]('Team,\x20%s,\x20%s,\x20%s',_0x5e497c,'request\x20sent',JSON[_0x6b66('0x12')](_0x5025c1));if(_0x5025c1[_0x6b66('0x13')]){if(_0x5025c1[_0x6b66('0x13')][_0x6b66('0x14')]===0x1f4){logger['error'](_0x6b66('0x10'),_0x5e497c,_0x5025c1[_0x6b66('0x13')][_0x6b66('0x15')]);return _0x2f5686(_0x5025c1[_0x6b66('0x13')][_0x6b66('0x15')]);}logger[_0x6b66('0x13')](_0x6b66('0x10'),_0x5e497c,_0x5025c1[_0x6b66('0x13')][_0x6b66('0x15')]);return _0x205a18(_0x5025c1[_0x6b66('0x13')][_0x6b66('0x15')]);}else{logger[_0x6b66('0xf')](_0x6b66('0x10'),_0x5e497c,_0x6b66('0x16'));_0x205a18(_0x5025c1['result'][_0x6b66('0x15')]);}})[_0x6b66('0x17')](function(_0x19c36e){logger[_0x6b66('0x13')](_0x6b66('0x10'),_0x5e497c,_0x19c36e);_0x2f5686(_0x19c36e);});});}