Built motion from commit 3c2ce842.|2.6.31
[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 _0x3823=['randomstring','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./team.socket','register','info','request\x20sent','debug','stringify','error','Team,\x20%s,\x20%s','message','catch','util','moment'];(function(_0x4c7ddb,_0x41a6cf){var _0x535cc8=function(_0x1ded3b){while(--_0x1ded3b){_0x4c7ddb['push'](_0x4c7ddb['shift']());}};_0x535cc8(++_0x41a6cf);}(_0x3823,0x71));var _0x3382=function(_0xcee411,_0x59f634){_0xcee411=_0xcee411-0x0;var _0x5c3735=_0x3823[_0xcee411];return _0x5c3735;};'use strict';var _=require('lodash');var util=require(_0x3382('0x0'));var moment=require(_0x3382('0x1'));var BPromise=require('bluebird');var rs=require(_0x3382('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x3382('0x3'));var logger=require(_0x3382('0x4'))(_0x3382('0x5'));var config=require('../../config/environment');var jayson=require(_0x3382('0x6'));var client=jayson[_0x3382('0x7')][_0x3382('0x8')]({'port':0x232a});config[_0x3382('0x9')]=_[_0x3382('0xa')](config['redis'],{'host':_0x3382('0xb'),'port':0x18eb});var socket=require(_0x3382('0xc'))(new Redis(config[_0x3382('0x9')]));require(_0x3382('0xd'))[_0x3382('0xe')](socket);function respondWithRpcPromise(_0x3d42ad,_0x2979e3,_0x29c771){return new BPromise(function(_0x5689e0,_0x34a3b7){return client['request'](_0x3d42ad,_0x29c771)['then'](function(_0x21022d){logger[_0x3382('0xf')]('Team,\x20%s,\x20%s',_0x2979e3,_0x3382('0x10'));logger[_0x3382('0x11')]('Team,\x20%s,\x20%s,\x20%s',_0x2979e3,_0x3382('0x10'),JSON[_0x3382('0x12')](_0x21022d));if(_0x21022d[_0x3382('0x13')]){if(_0x21022d[_0x3382('0x13')]['code']===0x1f4){logger[_0x3382('0x13')](_0x3382('0x14'),_0x2979e3,_0x21022d[_0x3382('0x13')][_0x3382('0x15')]);return _0x34a3b7(_0x21022d[_0x3382('0x13')][_0x3382('0x15')]);}logger[_0x3382('0x13')]('Team,\x20%s,\x20%s',_0x2979e3,_0x21022d[_0x3382('0x13')][_0x3382('0x15')]);return _0x5689e0(_0x21022d[_0x3382('0x13')][_0x3382('0x15')]);}else{logger['info'](_0x3382('0x14'),_0x2979e3,_0x3382('0x10'));_0x5689e0(_0x21022d['result'][_0x3382('0x15')]);}})[_0x3382('0x16')](function(_0x35b6a1){logger[_0x3382('0x13')](_0x3382('0x14'),_0x2979e3,_0x35b6a1);_0x34a3b7(_0x35b6a1);});});}