1b1ad6c6eaa059f211a55c21c9b094a2c74db02b
[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 _0x1b9a=['defaults','redis','localhost','./team.socket','register','info','Team,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','lodash','util','moment','../../mysqldb','../../config/environment','jayson/promise','http'];(function(_0x5062da,_0x4400d2){var _0x46d327=function(_0x269596){while(--_0x269596){_0x5062da['push'](_0x5062da['shift']());}};_0x46d327(++_0x4400d2);}(_0x1b9a,0x93));var _0xa1b9=function(_0x211a6c,_0x52ef7d){_0x211a6c=_0x211a6c-0x0;var _0x2a1ec4=_0x1b9a[_0x211a6c];return _0x2a1ec4;};'use strict';var _=require(_0xa1b9('0x0'));var util=require(_0xa1b9('0x1'));var moment=require(_0xa1b9('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa1b9('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0xa1b9('0x4'));var jayson=require(_0xa1b9('0x5'));var client=jayson['client'][_0xa1b9('0x6')]({'port':0x232a});config['redis']=_[_0xa1b9('0x7')](config[_0xa1b9('0x8')],{'host':_0xa1b9('0x9'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xa1b9('0x8')]));require(_0xa1b9('0xa'))[_0xa1b9('0xb')](socket);function respondWithRpcPromise(_0x1ff7a3,_0x5114a5,_0x3bdde0){return new BPromise(function(_0x14619e,_0x410c05){return client['request'](_0x1ff7a3,_0x3bdde0)['then'](function(_0x477ed4){logger[_0xa1b9('0xc')](_0xa1b9('0xd'),_0x5114a5,_0xa1b9('0xe'));logger[_0xa1b9('0xf')]('Team,\x20%s,\x20%s,\x20%s',_0x5114a5,_0xa1b9('0xe'),JSON[_0xa1b9('0x10')](_0x477ed4));if(_0x477ed4[_0xa1b9('0x11')]){if(_0x477ed4['error'][_0xa1b9('0x12')]===0x1f4){logger[_0xa1b9('0x11')](_0xa1b9('0xd'),_0x5114a5,_0x477ed4[_0xa1b9('0x11')]['message']);return _0x410c05(_0x477ed4['error'][_0xa1b9('0x13')]);}logger[_0xa1b9('0x11')]('Team,\x20%s,\x20%s',_0x5114a5,_0x477ed4[_0xa1b9('0x11')][_0xa1b9('0x13')]);return _0x14619e(_0x477ed4[_0xa1b9('0x11')][_0xa1b9('0x13')]);}else{logger['info'](_0xa1b9('0xd'),_0x5114a5,_0xa1b9('0xe'));_0x14619e(_0x477ed4[_0xa1b9('0x14')][_0xa1b9('0x13')]);}})[_0xa1b9('0x15')](function(_0x504994){logger[_0xa1b9('0x11')](_0xa1b9('0xd'),_0x5114a5,_0x504994);_0x410c05(_0x504994);});});}