5f1344c8497560ab9f449697456f4016c32d872c
[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 _0xa545=['stringify','error','code','message','info','result','util','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./team.socket','register','then','Team,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x44d4c4,_0x56ef8b){var _0x44ee0b=function(_0x3b3016){while(--_0x3b3016){_0x44d4c4['push'](_0x44d4c4['shift']());}};_0x44ee0b(++_0x56ef8b);}(_0xa545,0x14a));var _0x5a54=function(_0x1634bf,_0xda08a7){_0x1634bf=_0x1634bf-0x0;var _0x32643d=_0xa545[_0x1634bf];return _0x32643d;};'use strict';var _=require('lodash');var util=require(_0x5a54('0x0'));var moment=require('moment');var BPromise=require(_0x5a54('0x1'));var rs=require(_0x5a54('0x2'));var fs=require('fs');var Redis=require(_0x5a54('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x5a54('0x4'));var logger=require(_0x5a54('0x5'))(_0x5a54('0x6'));var config=require(_0x5a54('0x7'));var jayson=require(_0x5a54('0x8'));var client=jayson[_0x5a54('0x9')][_0x5a54('0xa')]({'port':0x232a});config[_0x5a54('0xb')]=_[_0x5a54('0xc')](config['redis'],{'host':_0x5a54('0xd'),'port':0x18eb});var socket=require(_0x5a54('0xe'))(new Redis(config[_0x5a54('0xb')]));require(_0x5a54('0xf'))[_0x5a54('0x10')](socket);function respondWithRpcPromise(_0x4dd676,_0x27480e,_0x2d9f7a){return new BPromise(function(_0x3169e5,_0x2cd2d3){return client['request'](_0x4dd676,_0x2d9f7a)[_0x5a54('0x11')](function(_0x333b6d){logger['info'](_0x5a54('0x12'),_0x27480e,_0x5a54('0x13'));logger[_0x5a54('0x14')]('Team,\x20%s,\x20%s,\x20%s',_0x27480e,_0x5a54('0x13'),JSON[_0x5a54('0x15')](_0x333b6d));if(_0x333b6d[_0x5a54('0x16')]){if(_0x333b6d['error'][_0x5a54('0x17')]===0x1f4){logger[_0x5a54('0x16')](_0x5a54('0x12'),_0x27480e,_0x333b6d[_0x5a54('0x16')][_0x5a54('0x18')]);return _0x2cd2d3(_0x333b6d[_0x5a54('0x16')][_0x5a54('0x18')]);}logger[_0x5a54('0x16')](_0x5a54('0x12'),_0x27480e,_0x333b6d[_0x5a54('0x16')]['message']);return _0x3169e5(_0x333b6d[_0x5a54('0x16')][_0x5a54('0x18')]);}else{logger[_0x5a54('0x19')](_0x5a54('0x12'),_0x27480e,_0x5a54('0x13'));_0x3169e5(_0x333b6d[_0x5a54('0x1a')]['message']);}})['catch'](function(_0x301501){logger['error']('Team,\x20%s,\x20%s',_0x27480e,_0x301501);_0x2cd2d3(_0x301501);});});}