d89da2409c7adbcec0dded7d7e7fa555e3043951
[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 _0x8c97=['bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','redis','localhost','./team.socket','register','request','info','Team,\x20%s,\x20%s','debug','Team,\x20%s,\x20%s,\x20%s','stringify','error','code','message','request\x20sent','result','catch','lodash','util'];(function(_0x1deee5,_0x1d4485){var _0x1d6c3a=function(_0x433abf){while(--_0x433abf){_0x1deee5['push'](_0x1deee5['shift']());}};_0x1d6c3a(++_0x1d4485);}(_0x8c97,0x1ae));var _0x78c9=function(_0x5bd713,_0x338476){_0x5bd713=_0x5bd713-0x0;var _0x569949=_0x8c97[_0x5bd713];return _0x569949;};'use strict';var _=require(_0x78c9('0x0'));var util=require(_0x78c9('0x1'));var moment=require('moment');var BPromise=require(_0x78c9('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x78c9('0x3'));var db=require(_0x78c9('0x4'))['db'];var utils=require(_0x78c9('0x5'));var logger=require(_0x78c9('0x6'))('rpc');var config=require(_0x78c9('0x7'));var jayson=require(_0x78c9('0x8'));var client=jayson[_0x78c9('0x9')][_0x78c9('0xa')]({'port':0x232a});config[_0x78c9('0xb')]=_['defaults'](config[_0x78c9('0xb')],{'host':_0x78c9('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x78c9('0xb')]));require(_0x78c9('0xd'))[_0x78c9('0xe')](socket);function respondWithRpcPromise(_0x1dfba9,_0x21b242,_0x12fb88){return new BPromise(function(_0x247763,_0xff8d78){return client[_0x78c9('0xf')](_0x1dfba9,_0x12fb88)['then'](function(_0x581b3d){logger[_0x78c9('0x10')](_0x78c9('0x11'),_0x21b242,'request\x20sent');logger[_0x78c9('0x12')](_0x78c9('0x13'),_0x21b242,'request\x20sent',JSON[_0x78c9('0x14')](_0x581b3d));if(_0x581b3d[_0x78c9('0x15')]){if(_0x581b3d[_0x78c9('0x15')][_0x78c9('0x16')]===0x1f4){logger[_0x78c9('0x15')](_0x78c9('0x11'),_0x21b242,_0x581b3d[_0x78c9('0x15')]['message']);return _0xff8d78(_0x581b3d[_0x78c9('0x15')][_0x78c9('0x17')]);}logger[_0x78c9('0x15')]('Team,\x20%s,\x20%s',_0x21b242,_0x581b3d[_0x78c9('0x15')]['message']);return _0x247763(_0x581b3d['error'][_0x78c9('0x17')]);}else{logger[_0x78c9('0x10')](_0x78c9('0x11'),_0x21b242,_0x78c9('0x18'));_0x247763(_0x581b3d[_0x78c9('0x19')]['message']);}})[_0x78c9('0x1a')](function(_0x99ef9a){logger[_0x78c9('0x15')](_0x78c9('0x11'),_0x21b242,_0x99ef9a);_0xff8d78(_0x99ef9a);});});}