3c454991fea9711453706912e4ff638629e4e28b
[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 _0x6c1f=['agents','catch','bluebird','./license/util','voice','chat','fax','sms','openchannel','getChannels','isValidChannel','includes','clearBlockUser','isUndefined','updateAttributes','getLicense','role','agent','then'];(function(_0x34110c,_0x7f09b7){var _0xabbc0a=function(_0x12cc0a){while(--_0x12cc0a){_0x34110c['push'](_0x34110c['shift']());}};_0xabbc0a(++_0x7f09b7);}(_0x6c1f,0x1ca));var _0xf6c1=function(_0x1bac4a,_0x34f93f){_0x1bac4a=_0x1bac4a-0x0;var _0x257a51=_0x6c1f[_0x1bac4a];return _0x257a51;};'use strict';var _=require('lodash');var BPromise=require(_0xf6c1('0x0'));var db=require('../mysqldb')['db'];var util=require(_0xf6c1('0x1'));var channels=[_0xf6c1('0x2'),'mail',_0xf6c1('0x3'),_0xf6c1('0x4'),_0xf6c1('0x5'),'whatsapp',_0xf6c1('0x6')];exports[_0xf6c1('0x7')]=function(){return channels;};exports[_0xf6c1('0x8')]=function(_0x5e6dd5){_0x5e6dd5=_0x5e6dd5['toLowerCase']();return _[_0xf6c1('0x9')](channels,_0x5e6dd5);};exports[_0xf6c1('0xa')]=function(_0x4c8c6c,_0x3bb62f,_0x2d3aa0,_0x3a6d95){var _0x3fb41e={'loginAttempts':_0x3bb62f,'blocked':_0x2d3aa0};if(!_[_0xf6c1('0xb')](_0x3a6d95)){_0x3fb41e['blockedAt']=_0x3a6d95;}return _0x4c8c6c[_0xf6c1('0xc')](_0x3fb41e);};exports[_0xf6c1('0xd')]=function(_0x2b4298){return new BPromise(function(_0x31b0c2,_0xe52d2c){var _0x3e6de1=0x0;if(_0x2b4298[_0xf6c1('0xe')]!==_0xf6c1('0xf')){_0x31b0c2(_0x2b4298);}db['User']['count']({'where':{'role':_0xf6c1('0xf'),'online':!![],'id':{'$ne':_0x2b4298['id']}}})[_0xf6c1('0x10')](function(_0x261968){_0x3e6de1=_0x261968;return util['getLicense']();})['then'](function(_0x1daf3f){if(_0x1daf3f&&_0x1daf3f[_0xf6c1('0x11')]&&_0x3e6de1>=_0x1daf3f[_0xf6c1('0x11')]){throw Error('Maximum\x20login\x20has\x20been\x20reached');}_0x31b0c2(_0x2b4298);})[_0xf6c1('0x12')](function(_0x561f69){_0xe52d2c(_0x561f69);});});};