e302777c47fea67432f8ea8eea10456937559135
[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 _0x2a03=['getChannels','toLowerCase','clearBlockUser','isUndefined','blockedAt','getLicense','role','agent','count','then','agents','Maximum\x20login\x20has\x20been\x20reached','catch','bluebird','./license/util','mail','chat','fax','sms','whatsapp','openchannel'];(function(_0x21cf1b,_0x77039d){var _0x2b4502=function(_0x254548){while(--_0x254548){_0x21cf1b['push'](_0x21cf1b['shift']());}};_0x2b4502(++_0x77039d);}(_0x2a03,0x133));var _0x32a0=function(_0x546f45,_0x3a0b48){_0x546f45=_0x546f45-0x0;var _0x3058cc=_0x2a03[_0x546f45];return _0x3058cc;};'use strict';var _=require('lodash');var BPromise=require(_0x32a0('0x0'));var db=require('../mysqldb')['db'];var util=require(_0x32a0('0x1'));var channels=['voice',_0x32a0('0x2'),_0x32a0('0x3'),_0x32a0('0x4'),_0x32a0('0x5'),_0x32a0('0x6'),_0x32a0('0x7')];exports[_0x32a0('0x8')]=function(){return channels;};exports['isValidChannel']=function(_0x35cb3e){_0x35cb3e=_0x35cb3e[_0x32a0('0x9')]();return _['includes'](channels,_0x35cb3e);};exports[_0x32a0('0xa')]=function(_0x374c6b,_0x2cc224,_0x4b320f,_0x129f28){var _0x371cfb={'loginAttempts':_0x2cc224,'blocked':_0x4b320f};if(!_[_0x32a0('0xb')](_0x129f28)){_0x371cfb[_0x32a0('0xc')]=_0x129f28;}return _0x374c6b['updateAttributes'](_0x371cfb);};exports[_0x32a0('0xd')]=function(_0x1aeb70){return new BPromise(function(_0x1f7038,_0x5e3092){var _0x594ffe=0x0;if(_0x1aeb70[_0x32a0('0xe')]!==_0x32a0('0xf')){_0x1f7038(_0x1aeb70);}db['User'][_0x32a0('0x10')]({'where':{'role':_0x32a0('0xf'),'online':!![],'id':{'$ne':_0x1aeb70['id']}}})[_0x32a0('0x11')](function(_0x2801d0){_0x594ffe=_0x2801d0;return util['getLicense']();})[_0x32a0('0x11')](function(_0x498bac){if(_0x498bac&&_0x498bac['agents']&&_0x594ffe>=_0x498bac[_0x32a0('0x12')]){throw Error(_0x32a0('0x13'));}_0x1f7038(_0x1aeb70);})[_0x32a0('0x14')](function(_0x5d4276){_0x5e3092(_0x5d4276);});});};