9f130f283fc2bfb6d87fb6ae8408925c57f45913
[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 _0x88cb=['chat','fax','whatsapp','getChannels','isValidChannel','includes','clearBlockUser','isUndefined','blockedAt','updateAttributes','getLicense','agent','User','then','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','bluebird','../mysqldb','./license/util','voice','mail'];(function(_0x2e819c,_0x3f99a5){var _0x24e271=function(_0x27d596){while(--_0x27d596){_0x2e819c['push'](_0x2e819c['shift']());}};_0x24e271(++_0x3f99a5);}(_0x88cb,0x198));var _0xb88c=function(_0x1facfa,_0x1acf7d){_0x1facfa=_0x1facfa-0x0;var _0x9ec701=_0x88cb[_0x1facfa];return _0x9ec701;};'use strict';var _=require(_0xb88c('0x0'));var BPromise=require(_0xb88c('0x1'));var db=require(_0xb88c('0x2'))['db'];var util=require(_0xb88c('0x3'));var channels=[_0xb88c('0x4'),_0xb88c('0x5'),_0xb88c('0x6'),_0xb88c('0x7'),'sms',_0xb88c('0x8'),'openchannel'];exports[_0xb88c('0x9')]=function(){return channels;};exports[_0xb88c('0xa')]=function(_0x2625f5){_0x2625f5=_0x2625f5['toLowerCase']();return _[_0xb88c('0xb')](channels,_0x2625f5);};exports[_0xb88c('0xc')]=function(_0x38fba4,_0x41a8fe,_0x3aa53c,_0x5524d5){var _0x240ae6={'loginAttempts':_0x41a8fe,'blocked':_0x3aa53c};if(!_[_0xb88c('0xd')](_0x5524d5)){_0x240ae6[_0xb88c('0xe')]=_0x5524d5;}return _0x38fba4[_0xb88c('0xf')](_0x240ae6);};exports[_0xb88c('0x10')]=function(_0x365316){return new BPromise(function(_0xaa8287,_0x495dcd){var _0x230a3d=0x0;if(_0x365316['role']!==_0xb88c('0x11')){_0xaa8287(_0x365316);}db[_0xb88c('0x12')]['count']({'where':{'role':_0xb88c('0x11'),'online':!![],'id':{'$ne':_0x365316['id']}}})[_0xb88c('0x13')](function(_0x39f3ad){_0x230a3d=_0x39f3ad;return util[_0xb88c('0x10')]();})[_0xb88c('0x13')](function(_0x57ee97){if(_0x57ee97&&_0x57ee97[_0xb88c('0x14')]&&_0x230a3d>=_0x57ee97[_0xb88c('0x14')]){throw Error(_0xb88c('0x15'));}_0xaa8287(_0x365316);})[_0xb88c('0x16')](function(_0x1e607d){_0x495dcd(_0x1e607d);});});};