31144fe2c864797b3144e4db3061b0b88c1e1a2f
[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 _0x50dc=['request\x20sent','stringify','error','code','message','util','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','./team.socket','request','then','info','Team,\x20%s,\x20%s'];(function(_0x5b42bd,_0x3d0de5){var _0x51a035=function(_0x5670e7){while(--_0x5670e7){_0x5b42bd['push'](_0x5b42bd['shift']());}};_0x51a035(++_0x3d0de5);}(_0x50dc,0x194));var _0xc50d=function(_0x152b8b,_0x4a55da){_0x152b8b=_0x152b8b-0x0;var _0xf01ac6=_0x50dc[_0x152b8b];return _0xf01ac6;};'use strict';var _=require('lodash');var util=require(_0xc50d('0x0'));var moment=require('moment');var BPromise=require(_0xc50d('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xc50d('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0xc50d('0x3'));var logger=require(_0xc50d('0x4'))(_0xc50d('0x5'));var config=require(_0xc50d('0x6'));var jayson=require(_0xc50d('0x7'));var client=jayson[_0xc50d('0x8')][_0xc50d('0x9')]({'port':0x232a});config[_0xc50d('0xa')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xc50d('0xb'))['register'](socket);function respondWithRpcPromise(_0x35152b,_0x22a28d,_0x410bda){return new BPromise(function(_0x3a1ad8,_0x1e63f4){return client[_0xc50d('0xc')](_0x35152b,_0x410bda)[_0xc50d('0xd')](function(_0x285f69){logger[_0xc50d('0xe')](_0xc50d('0xf'),_0x22a28d,_0xc50d('0x10'));logger['debug']('Team,\x20%s,\x20%s,\x20%s',_0x22a28d,_0xc50d('0x10'),JSON[_0xc50d('0x11')](_0x285f69));if(_0x285f69[_0xc50d('0x12')]){if(_0x285f69[_0xc50d('0x12')][_0xc50d('0x13')]===0x1f4){logger[_0xc50d('0x12')](_0xc50d('0xf'),_0x22a28d,_0x285f69[_0xc50d('0x12')]['message']);return _0x1e63f4(_0x285f69[_0xc50d('0x12')]['message']);}logger[_0xc50d('0x12')](_0xc50d('0xf'),_0x22a28d,_0x285f69[_0xc50d('0x12')]['message']);return _0x3a1ad8(_0x285f69[_0xc50d('0x12')][_0xc50d('0x14')]);}else{logger['info']('Team,\x20%s,\x20%s',_0x22a28d,_0xc50d('0x10'));_0x3a1ad8(_0x285f69['result'][_0xc50d('0x14')]);}})['catch'](function(_0x43c420){logger[_0xc50d('0x12')]('Team,\x20%s,\x20%s',_0x22a28d,_0x43c420);_0x1e63f4(_0x43c420);});});}