874352cb1c4701c313d9ccd03e788dc78992f3e0
[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 _0xaba4=['bluebird','randomstring','ioredis','jayson/promise','http','redis','defaults','register','request','then','info','Team,\x20%s,\x20%s','request\x20sent','debug','Team,\x20%s,\x20%s,\x20%s','stringify','error','code','message','util','moment'];(function(_0x1e4f2f,_0x35edfa){var _0xccea89=function(_0x164386){while(--_0x164386){_0x1e4f2f['push'](_0x1e4f2f['shift']());}};_0xccea89(++_0x35edfa);}(_0xaba4,0xfa));var _0x4aba=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xaba4[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var util=require(_0x4aba('0x0'));var moment=require(_0x4aba('0x1'));var BPromise=require(_0x4aba('0x2'));var rs=require(_0x4aba('0x3'));var fs=require('fs');var Redis=require(_0x4aba('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x4aba('0x5'));var client=jayson['client'][_0x4aba('0x6')]({'port':0x232a});config[_0x4aba('0x7')]=_[_0x4aba('0x8')](config[_0x4aba('0x7')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x4aba('0x7')]));require('./team.socket')[_0x4aba('0x9')](socket);function respondWithRpcPromise(_0x156ec5,_0x2eec25,_0x370a7c){return new BPromise(function(_0xcea161,_0x2e3124){return client[_0x4aba('0xa')](_0x156ec5,_0x370a7c)[_0x4aba('0xb')](function(_0x3b9a40){logger[_0x4aba('0xc')](_0x4aba('0xd'),_0x2eec25,_0x4aba('0xe'));logger[_0x4aba('0xf')](_0x4aba('0x10'),_0x2eec25,'request\x20sent',JSON[_0x4aba('0x11')](_0x3b9a40));if(_0x3b9a40[_0x4aba('0x12')]){if(_0x3b9a40[_0x4aba('0x12')][_0x4aba('0x13')]===0x1f4){logger[_0x4aba('0x12')](_0x4aba('0xd'),_0x2eec25,_0x3b9a40['error'][_0x4aba('0x14')]);return _0x2e3124(_0x3b9a40[_0x4aba('0x12')][_0x4aba('0x14')]);}logger[_0x4aba('0x12')](_0x4aba('0xd'),_0x2eec25,_0x3b9a40[_0x4aba('0x12')][_0x4aba('0x14')]);return _0xcea161(_0x3b9a40[_0x4aba('0x12')][_0x4aba('0x14')]);}else{logger['info'](_0x4aba('0xd'),_0x2eec25,_0x4aba('0xe'));_0xcea161(_0x3b9a40['result'][_0x4aba('0x14')]);}})['catch'](function(_0x586d2f){logger[_0x4aba('0x12')](_0x4aba('0xd'),_0x2eec25,_0x586d2f);_0x2e3124(_0x586d2f);});});}