9ade7702d88cf752e0558ea16cb5fdfb7d132742
[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 _0x01e2=['User','count','then','agents','Maximum\x20login\x20has\x20been\x20reached','bluebird','../mysqldb','./license/util','voice','chat','fax','sms','openchannel','getChannels','isValidChannel','toLowerCase','clearBlockUser','isUndefined','blockedAt','updateAttributes','getLicense','agent'];(function(_0x508a0a,_0x3ed316){var _0x4acf06=function(_0x9cea61){while(--_0x9cea61){_0x508a0a['push'](_0x508a0a['shift']());}};_0x4acf06(++_0x3ed316);}(_0x01e2,0x123));var _0x201e=function(_0x57b51e,_0x3f9e16){_0x57b51e=_0x57b51e-0x0;var _0x1efb57=_0x01e2[_0x57b51e];return _0x1efb57;};'use strict';var _=require('lodash');var BPromise=require(_0x201e('0x0'));var db=require(_0x201e('0x1'))['db'];var util=require(_0x201e('0x2'));var channels=[_0x201e('0x3'),'mail',_0x201e('0x4'),_0x201e('0x5'),_0x201e('0x6'),'whatsapp',_0x201e('0x7')];exports[_0x201e('0x8')]=function(){return channels;};exports[_0x201e('0x9')]=function(_0x49157d){_0x49157d=_0x49157d[_0x201e('0xa')]();return _['includes'](channels,_0x49157d);};exports[_0x201e('0xb')]=function(_0x3d5b36,_0x4b0ffc,_0x34ea07,_0x2ddd47){var _0x350d4b={'loginAttempts':_0x4b0ffc,'blocked':_0x34ea07};if(!_[_0x201e('0xc')](_0x2ddd47)){_0x350d4b[_0x201e('0xd')]=_0x2ddd47;}return _0x3d5b36[_0x201e('0xe')](_0x350d4b);};exports[_0x201e('0xf')]=function(_0x2e76e5){return new BPromise(function(_0xef0b91,_0x278638){var _0x467af7=0x0;if(_0x2e76e5['role']!==_0x201e('0x10')){_0xef0b91(_0x2e76e5);}db[_0x201e('0x11')][_0x201e('0x12')]({'where':{'role':_0x201e('0x10'),'online':!![],'id':{'$ne':_0x2e76e5['id']}}})[_0x201e('0x13')](function(_0x57638e){_0x467af7=_0x57638e;return util[_0x201e('0xf')]();})[_0x201e('0x13')](function(_0x2aa7b0){if(_0x2aa7b0&&_0x2aa7b0[_0x201e('0x14')]&&_0x467af7>=_0x2aa7b0[_0x201e('0x14')]){throw Error(_0x201e('0x15'));}_0xef0b91(_0x2e76e5);})['catch'](function(_0x596108){_0x278638(_0x596108);});});};