4a0c68fd74d93c84eedc3e81b4f4a3b7fbd13c46
[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 _0x5512=['voice','mail','chat','fax','sms','whatsapp','getChannels','isValidChannel','toLowerCase','includes','isUndefined','updateAttributes','getLicense','role','agent','User','count','then','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','bluebird','./license/util'];(function(_0x402d5e,_0x78fe63){var _0x1fdf3f=function(_0x451e9e){while(--_0x451e9e){_0x402d5e['push'](_0x402d5e['shift']());}};_0x1fdf3f(++_0x78fe63);}(_0x5512,0x8d));var _0x2551=function(_0x3794cb,_0x2e1464){_0x3794cb=_0x3794cb-0x0;var _0x2377dd=_0x5512[_0x3794cb];return _0x2377dd;};'use strict';var _=require(_0x2551('0x0'));var BPromise=require(_0x2551('0x1'));var db=require('../mysqldb')['db'];var util=require(_0x2551('0x2'));var channels=[_0x2551('0x3'),_0x2551('0x4'),_0x2551('0x5'),_0x2551('0x6'),_0x2551('0x7'),_0x2551('0x8'),'openchannel'];exports[_0x2551('0x9')]=function(){return channels;};exports[_0x2551('0xa')]=function(_0x1e603f){_0x1e603f=_0x1e603f[_0x2551('0xb')]();return _[_0x2551('0xc')](channels,_0x1e603f);};exports['clearBlockUser']=function(_0x447e74,_0x3cbdb9,_0x30ef89,_0xd5b647){var _0x1b7194={'loginAttempts':_0x3cbdb9,'blocked':_0x30ef89};if(!_[_0x2551('0xd')](_0xd5b647)){_0x1b7194['blockedAt']=_0xd5b647;}return _0x447e74[_0x2551('0xe')](_0x1b7194);};exports[_0x2551('0xf')]=function(_0x45eeb4){return new BPromise(function(_0x4b5bb2,_0x34bee4){var _0xb9d744=0x0;if(_0x45eeb4[_0x2551('0x10')]!==_0x2551('0x11')){_0x4b5bb2(_0x45eeb4);}db[_0x2551('0x12')][_0x2551('0x13')]({'where':{'role':_0x2551('0x11'),'online':!![],'id':{'$ne':_0x45eeb4['id']}}})['then'](function(_0x4359c2){_0xb9d744=_0x4359c2;return util[_0x2551('0xf')]();})[_0x2551('0x14')](function(_0x955427){if(_0x955427&&_0x955427['agents']&&_0xb9d744>=_0x955427[_0x2551('0x15')]){throw Error(_0x2551('0x16'));}_0x4b5bb2(_0x45eeb4);})[_0x2551('0x17')](function(_0x4d6bea){_0x34bee4(_0x4d6bea);});});};