Built motion from commit 351e7f9c.|2.6.31
[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 _0x2616=['chat','fax','whatsapp','openchannel','getChannels','isValidChannel','includes','clearBlockUser','blockedAt','updateAttributes','agent','User','getLicense','then','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','bluebird','./license/util','voice','mail'];(function(_0x4387dc,_0x2e873c){var _0x5cc41a=function(_0x4ce3bb){while(--_0x4ce3bb){_0x4387dc['push'](_0x4387dc['shift']());}};_0x5cc41a(++_0x2e873c);}(_0x2616,0x15b));var _0x6261=function(_0x555069,_0x23d66a){_0x555069=_0x555069-0x0;var _0x100af7=_0x2616[_0x555069];return _0x100af7;};'use strict';var _=require(_0x6261('0x0'));var BPromise=require(_0x6261('0x1'));var db=require('../mysqldb')['db'];var util=require(_0x6261('0x2'));var channels=[_0x6261('0x3'),_0x6261('0x4'),_0x6261('0x5'),_0x6261('0x6'),'sms',_0x6261('0x7'),_0x6261('0x8')];exports[_0x6261('0x9')]=function(){return channels;};exports[_0x6261('0xa')]=function(_0x15b226){_0x15b226=_0x15b226['toLowerCase']();return _[_0x6261('0xb')](channels,_0x15b226);};exports[_0x6261('0xc')]=function(_0x425655,_0x29a81b,_0x1edb34,_0x4e9c18){var _0x5a0380={'loginAttempts':_0x29a81b,'blocked':_0x1edb34};if(!_['isUndefined'](_0x4e9c18)){_0x5a0380[_0x6261('0xd')]=_0x4e9c18;}return _0x425655[_0x6261('0xe')](_0x5a0380);};exports['getLicense']=function(_0x670e5e){return new BPromise(function(_0x375c35,_0x1671a2){var _0x15d7d5=0x0;if(_0x670e5e['role']!==_0x6261('0xf')){_0x375c35(_0x670e5e);}db[_0x6261('0x10')]['count']({'where':{'role':_0x6261('0xf'),'online':!![],'id':{'$ne':_0x670e5e['id']}}})['then'](function(_0x18988a){_0x15d7d5=_0x18988a;return util[_0x6261('0x11')]();})[_0x6261('0x12')](function(_0x40fcad){if(_0x40fcad&&_0x40fcad[_0x6261('0x13')]&&_0x15d7d5>=_0x40fcad[_0x6261('0x13')]){throw Error(_0x6261('0x14'));}_0x375c35(_0x670e5e);})[_0x6261('0x15')](function(_0x5e7767){_0x1671a2(_0x5e7767);});});};