289712257b023a6d3a9e204512b291203c5fe803
[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 _0xf841=['then','getLicense','agents','Maximum\x20login\x20has\x20been\x20reached','catch','lodash','bluebird','../mysqldb','./license/util','voice','chat','fax','getChannels','toLowerCase','includes','isUndefined','blockedAt','updateAttributes','role','User','count','agent'];(function(_0x199ac7,_0x5ac733){var _0x41f2b9=function(_0x4dc3b3){while(--_0x4dc3b3){_0x199ac7['push'](_0x199ac7['shift']());}};_0x41f2b9(++_0x5ac733);}(_0xf841,0x89));var _0x1f84=function(_0x4dab14,_0x164ea0){_0x4dab14=_0x4dab14-0x0;var _0xf41aa=_0xf841[_0x4dab14];return _0xf41aa;};'use strict';var _=require(_0x1f84('0x0'));var BPromise=require(_0x1f84('0x1'));var db=require(_0x1f84('0x2'))['db'];var util=require(_0x1f84('0x3'));var channels=[_0x1f84('0x4'),'mail',_0x1f84('0x5'),_0x1f84('0x6'),'sms','whatsapp','openchannel'];exports[_0x1f84('0x7')]=function(){return channels;};exports['isValidChannel']=function(_0x472070){_0x472070=_0x472070[_0x1f84('0x8')]();return _[_0x1f84('0x9')](channels,_0x472070);};exports['clearBlockUser']=function(_0x241286,_0x4261f0,_0x181891,_0x28b101){var _0x432f9b={'loginAttempts':_0x4261f0,'blocked':_0x181891};if(!_[_0x1f84('0xa')](_0x28b101)){_0x432f9b[_0x1f84('0xb')]=_0x28b101;}return _0x241286[_0x1f84('0xc')](_0x432f9b);};exports['getLicense']=function(_0x4323ac){return new BPromise(function(_0x29c071,_0x42b28c){var _0x573c85=0x0;if(_0x4323ac[_0x1f84('0xd')]!=='agent'){_0x29c071(_0x4323ac);}db[_0x1f84('0xe')][_0x1f84('0xf')]({'where':{'role':_0x1f84('0x10'),'online':!![],'id':{'$ne':_0x4323ac['id']}}})[_0x1f84('0x11')](function(_0x15ccd4){_0x573c85=_0x15ccd4;return util[_0x1f84('0x12')]();})[_0x1f84('0x11')](function(_0x58891d){if(_0x58891d&&_0x58891d[_0x1f84('0x13')]&&_0x573c85>=_0x58891d[_0x1f84('0x13')]){throw Error(_0x1f84('0x14'));}_0x29c071(_0x4323ac);})[_0x1f84('0x15')](function(_0x191b7e){_0x42b28c(_0x191b7e);});});};