f138fdd235e10009bdc4967c3215843bb300c40a
[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 _0x5e0c=['then','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','bluebird','mail','chat','fax','sms','whatsapp','openchannel','isValidChannel','includes','blockedAt','getLicense','role','agent','User','count'];(function(_0xfdca,_0x179a1c){var _0x4ebbf0=function(_0x325d05){while(--_0x325d05){_0xfdca['push'](_0xfdca['shift']());}};_0x4ebbf0(++_0x179a1c);}(_0x5e0c,0x1d0));var _0xc5e0=function(_0x91d498,_0x482a89){_0x91d498=_0x91d498-0x0;var _0x1e0294=_0x5e0c[_0x91d498];return _0x1e0294;};'use strict';var _=require(_0xc5e0('0x0'));var BPromise=require(_0xc5e0('0x1'));var db=require('../mysqldb')['db'];var util=require('./license/util');var channels=['voice',_0xc5e0('0x2'),_0xc5e0('0x3'),_0xc5e0('0x4'),_0xc5e0('0x5'),_0xc5e0('0x6'),_0xc5e0('0x7')];exports['getChannels']=function(){return channels;};exports[_0xc5e0('0x8')]=function(_0x1c06c5){_0x1c06c5=_0x1c06c5['toLowerCase']();return _[_0xc5e0('0x9')](channels,_0x1c06c5);};exports['clearBlockUser']=function(_0x5afafe,_0x50dd0e,_0x19618c,_0x213dc9){var _0x3f8873={'loginAttempts':_0x50dd0e,'blocked':_0x19618c};if(!_['isUndefined'](_0x213dc9)){_0x3f8873[_0xc5e0('0xa')]=_0x213dc9;}return _0x5afafe['updateAttributes'](_0x3f8873);};exports[_0xc5e0('0xb')]=function(_0x3421bf){return new BPromise(function(_0x3e9b0d,_0x39e95c){var _0xcf02cf=0x0;if(_0x3421bf[_0xc5e0('0xc')]!==_0xc5e0('0xd')){_0x3e9b0d(_0x3421bf);}db[_0xc5e0('0xe')][_0xc5e0('0xf')]({'where':{'role':_0xc5e0('0xd'),'online':!![],'id':{'$ne':_0x3421bf['id']}}})[_0xc5e0('0x10')](function(_0x6e2179){_0xcf02cf=_0x6e2179;return util['getLicense']();})[_0xc5e0('0x10')](function(_0x26fabe){if(_0x26fabe&&_0x26fabe[_0xc5e0('0x11')]&&_0xcf02cf>=_0x26fabe[_0xc5e0('0x11')]){throw Error(_0xc5e0('0x12'));}_0x3e9b0d(_0x3421bf);})[_0xc5e0('0x13')](function(_0x2c049e){_0x39e95c(_0x2c049e);});});};