6b3336d33c0b6ac146ad45d1ff56cb3d7ae673e3
[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 _0xbdda=['then','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','bluebird','../mysqldb','./license/util','voice','mail','chat','fax','sms','whatsapp','openchannel','getChannels','toLowerCase','isUndefined','blockedAt','updateAttributes','getLicense','agent','count'];(function(_0x21ee4f,_0x360b81){var _0x1a3ec7=function(_0x3b9d84){while(--_0x3b9d84){_0x21ee4f['push'](_0x21ee4f['shift']());}};_0x1a3ec7(++_0x360b81);}(_0xbdda,0x1b9));var _0xabdd=function(_0x45bf2f,_0x14efce){_0x45bf2f=_0x45bf2f-0x0;var _0x202857=_0xbdda[_0x45bf2f];return _0x202857;};'use strict';var _=require(_0xabdd('0x0'));var BPromise=require(_0xabdd('0x1'));var db=require(_0xabdd('0x2'))['db'];var util=require(_0xabdd('0x3'));var channels=[_0xabdd('0x4'),_0xabdd('0x5'),_0xabdd('0x6'),_0xabdd('0x7'),_0xabdd('0x8'),_0xabdd('0x9'),_0xabdd('0xa')];exports[_0xabdd('0xb')]=function(){return channels;};exports['isValidChannel']=function(_0x27e118){_0x27e118=_0x27e118[_0xabdd('0xc')]();return _['includes'](channels,_0x27e118);};exports['clearBlockUser']=function(_0x810395,_0x3f2fc7,_0x594191,_0x46b4ab){var _0x21f9c1={'loginAttempts':_0x3f2fc7,'blocked':_0x594191};if(!_[_0xabdd('0xd')](_0x46b4ab)){_0x21f9c1[_0xabdd('0xe')]=_0x46b4ab;}return _0x810395[_0xabdd('0xf')](_0x21f9c1);};exports[_0xabdd('0x10')]=function(_0x42fd96){return new BPromise(function(_0x1abd7e,_0x5c6370){var _0xed8139=0x0;if(_0x42fd96['role']!==_0xabdd('0x11')){_0x1abd7e(_0x42fd96);}db['User'][_0xabdd('0x12')]({'where':{'role':'agent','online':!![],'id':{'$ne':_0x42fd96['id']}}})['then'](function(_0x3a29a1){_0xed8139=_0x3a29a1;return util['getLicense']();})[_0xabdd('0x13')](function(_0x3fbef0){if(_0x3fbef0&&_0x3fbef0[_0xabdd('0x14')]&&_0xed8139>=_0x3fbef0['agents']){throw Error(_0xabdd('0x15'));}_0x1abd7e(_0x42fd96);})[_0xabdd('0x16')](function(_0x3e2803){_0x5c6370(_0x3e2803);});});};