c5d00af9d316ae9392f5c9827d55c8913ff39496
[motion2.git] / server / config / utils.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 _0xce06=['updateAttributes','User','count','then','agents','catch','bluebird','../mysqldb','./license/util','mail','chat','fax','sms','whatsapp','openchannel','isValidChannel','toLowerCase','includes','clearBlockUser','isUndefined','blockedAt'];(function(_0x1dc403,_0x5d4361){var _0x34b3f0=function(_0x31cad8){while(--_0x31cad8){_0x1dc403['push'](_0x1dc403['shift']());}};_0x34b3f0(++_0x5d4361);}(_0xce06,0xc3));var _0x6ce0=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xce06[_0x321bb2];return _0x9c12ed;};'use strict';var _=require('lodash');var BPromise=require(_0x6ce0('0x0'));var db=require(_0x6ce0('0x1'))['db'];var util=require(_0x6ce0('0x2'));var channels=['voice',_0x6ce0('0x3'),_0x6ce0('0x4'),_0x6ce0('0x5'),_0x6ce0('0x6'),_0x6ce0('0x7'),_0x6ce0('0x8')];exports['getChannels']=function(){return channels;};exports[_0x6ce0('0x9')]=function(_0x39d63d){_0x39d63d=_0x39d63d[_0x6ce0('0xa')]();return _[_0x6ce0('0xb')](channels,_0x39d63d);};exports[_0x6ce0('0xc')]=function(_0x2a7e39,_0x1a8cc2,_0x2acd21,_0x333666){var _0x20805d={'loginAttempts':_0x1a8cc2,'blocked':_0x2acd21};if(!_[_0x6ce0('0xd')](_0x333666)){_0x20805d[_0x6ce0('0xe')]=_0x333666;}return _0x2a7e39[_0x6ce0('0xf')](_0x20805d);};exports['getLicense']=function(_0x35cf90){return new BPromise(function(_0xe95103,_0x47d335){var _0x5b6149=0x0;if(_0x35cf90['role']!=='agent'){_0xe95103(_0x35cf90);}db[_0x6ce0('0x10')][_0x6ce0('0x11')]({'where':{'role':'agent','online':!![],'id':{'$ne':_0x35cf90['id']}}})[_0x6ce0('0x12')](function(_0x356bdc){_0x5b6149=_0x356bdc;return util['getLicense']();})['then'](function(_0x26d004){if(_0x26d004&&_0x26d004[_0x6ce0('0x13')]&&_0x5b6149>=_0x26d004['agents']){throw Error('Maximum\x20login\x20has\x20been\x20reached');}_0xe95103(_0x35cf90);})[_0x6ce0('0x14')](function(_0x2cc6a0){_0x47d335(_0x2cc6a0);});});};