01d6929c35f34f3b948b02df2321fb7945bf2c2d
[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 _0xb2e4=['role','agent','User','count','then','agents','Maximum\x20login\x20has\x20been\x20reached','../mysqldb','voice','mail','chat','fax','sms','whatsapp','openchannel','getChannels','isValidChannel','toLowerCase','includes','clearBlockUser','isUndefined','updateAttributes','getLicense'];(function(_0x4b7973,_0x2532ff){var _0x35ffdf=function(_0x50cf4b){while(--_0x50cf4b){_0x4b7973['push'](_0x4b7973['shift']());}};_0x35ffdf(++_0x2532ff);}(_0xb2e4,0xbf));var _0x4b2e=function(_0x51bda1,_0x44f80d){_0x51bda1=_0x51bda1-0x0;var _0x1ce08c=_0xb2e4[_0x51bda1];return _0x1ce08c;};'use strict';var _=require('lodash');var BPromise=require('bluebird');var db=require(_0x4b2e('0x0'))['db'];var util=require('./license/util');var channels=[_0x4b2e('0x1'),_0x4b2e('0x2'),_0x4b2e('0x3'),_0x4b2e('0x4'),_0x4b2e('0x5'),_0x4b2e('0x6'),_0x4b2e('0x7')];exports[_0x4b2e('0x8')]=function(){return channels;};exports[_0x4b2e('0x9')]=function(_0x5cf919){_0x5cf919=_0x5cf919[_0x4b2e('0xa')]();return _[_0x4b2e('0xb')](channels,_0x5cf919);};exports[_0x4b2e('0xc')]=function(_0x5a3864,_0x22668c,_0x41ec03,_0x55ca34){var _0x52cc0f={'loginAttempts':_0x22668c,'blocked':_0x41ec03};if(!_[_0x4b2e('0xd')](_0x55ca34)){_0x52cc0f['blockedAt']=_0x55ca34;}return _0x5a3864[_0x4b2e('0xe')](_0x52cc0f);};exports[_0x4b2e('0xf')]=function(_0x45812c){return new BPromise(function(_0x5992c1,_0x50f8ca){var _0x288844=0x0;if(_0x45812c[_0x4b2e('0x10')]!==_0x4b2e('0x11')){_0x5992c1(_0x45812c);}db[_0x4b2e('0x12')][_0x4b2e('0x13')]({'where':{'role':_0x4b2e('0x11'),'online':!![],'id':{'$ne':_0x45812c['id']}}})[_0x4b2e('0x14')](function(_0x1680df){_0x288844=_0x1680df;return util[_0x4b2e('0xf')]();})[_0x4b2e('0x14')](function(_0x237fcc){if(_0x237fcc&&_0x237fcc[_0x4b2e('0x15')]&&_0x288844>=_0x237fcc[_0x4b2e('0x15')]){throw Error(_0x4b2e('0x16'));}_0x5992c1(_0x45812c);})['catch'](function(_0x19f138){_0x50f8ca(_0x19f138);});});};