96b5ec05c888f772eb7575601b508a2e2ded20a5
[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 _0x09ca=['jayson/promise','client','http','redis','defaults','socket.io-emitter','./team.socket','register','request','then','info','Team,\x20%s,\x20%s','Team,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','catch','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment'];(function(_0x4565bf,_0x5ad9d6){var _0x5610ba=function(_0x170988){while(--_0x170988){_0x4565bf['push'](_0x4565bf['shift']());}};_0x5610ba(++_0x5ad9d6);}(_0x09ca,0x189));var _0xa09c=function(_0x5dd9c5,_0x1ad161){_0x5dd9c5=_0x5dd9c5-0x0;var _0x38088b=_0x09ca[_0x5dd9c5];return _0x38088b;};'use strict';var _=require(_0xa09c('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xa09c('0x1'));var rs=require(_0xa09c('0x2'));var fs=require('fs');var Redis=require(_0xa09c('0x3'));var db=require(_0xa09c('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xa09c('0x5'))('rpc');var config=require(_0xa09c('0x6'));var jayson=require(_0xa09c('0x7'));var client=jayson[_0xa09c('0x8')][_0xa09c('0x9')]({'port':0x232a});config[_0xa09c('0xa')]=_[_0xa09c('0xb')](config[_0xa09c('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0xa09c('0xc'))(new Redis(config[_0xa09c('0xa')]));require(_0xa09c('0xd'))[_0xa09c('0xe')](socket);function respondWithRpcPromise(_0x5e7216,_0x5865f3,_0xd2871e){return new BPromise(function(_0x163cb6,_0x573c7){return client[_0xa09c('0xf')](_0x5e7216,_0xd2871e)[_0xa09c('0x10')](function(_0x3a5aa5){logger[_0xa09c('0x11')](_0xa09c('0x12'),_0x5865f3,'request\x20sent');logger['debug'](_0xa09c('0x13'),_0x5865f3,_0xa09c('0x14'),JSON[_0xa09c('0x15')](_0x3a5aa5));if(_0x3a5aa5[_0xa09c('0x16')]){if(_0x3a5aa5[_0xa09c('0x16')]['code']===0x1f4){logger['error'](_0xa09c('0x12'),_0x5865f3,_0x3a5aa5['error'][_0xa09c('0x17')]);return _0x573c7(_0x3a5aa5['error'][_0xa09c('0x17')]);}logger['error']('Team,\x20%s,\x20%s',_0x5865f3,_0x3a5aa5[_0xa09c('0x16')]['message']);return _0x163cb6(_0x3a5aa5['error']['message']);}else{logger[_0xa09c('0x11')](_0xa09c('0x12'),_0x5865f3,'request\x20sent');_0x163cb6(_0x3a5aa5['result'][_0xa09c('0x17')]);}})[_0xa09c('0x18')](function(_0x2fce1c){logger[_0xa09c('0x16')](_0xa09c('0x12'),_0x5865f3,_0x2fce1c);_0x573c7(_0x2fce1c);});});}