65e50d7143e3b648e5d4a786c4c8a2e53269cb0a
[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 _0x0a7b=['agent','User','count','then','Maximum\x20login\x20has\x20been\x20reached','catch','bluebird','../mysqldb','mail','chat','fax','sms','openchannel','getChannels','includes','clearBlockUser','isUndefined','blockedAt','role'];(function(_0x56e1bb,_0xb788d0){var _0x43ddfe=function(_0x103947){while(--_0x103947){_0x56e1bb['push'](_0x56e1bb['shift']());}};_0x43ddfe(++_0xb788d0);}(_0x0a7b,0xc4));var _0xb0a7=function(_0x4dd837,_0x4960ab){_0x4dd837=_0x4dd837-0x0;var _0xe32966=_0x0a7b[_0x4dd837];return _0xe32966;};'use strict';var _=require('lodash');var BPromise=require(_0xb0a7('0x0'));var db=require(_0xb0a7('0x1'))['db'];var util=require('./license/util');var channels=['voice',_0xb0a7('0x2'),_0xb0a7('0x3'),_0xb0a7('0x4'),_0xb0a7('0x5'),'whatsapp',_0xb0a7('0x6')];exports[_0xb0a7('0x7')]=function(){return channels;};exports['isValidChannel']=function(_0x5d5c54){_0x5d5c54=_0x5d5c54['toLowerCase']();return _[_0xb0a7('0x8')](channels,_0x5d5c54);};exports[_0xb0a7('0x9')]=function(_0xc3a97e,_0x21409f,_0x33a17a,_0x438bbb){var _0x29bbf2={'loginAttempts':_0x21409f,'blocked':_0x33a17a};if(!_[_0xb0a7('0xa')](_0x438bbb)){_0x29bbf2[_0xb0a7('0xb')]=_0x438bbb;}return _0xc3a97e['updateAttributes'](_0x29bbf2);};exports['getLicense']=function(_0x4eaea5){return new BPromise(function(_0x1402b5,_0x25a063){var _0x545a23=0x0;if(_0x4eaea5[_0xb0a7('0xc')]!==_0xb0a7('0xd')){_0x1402b5(_0x4eaea5);}db[_0xb0a7('0xe')][_0xb0a7('0xf')]({'where':{'role':_0xb0a7('0xd'),'online':!![],'id':{'$ne':_0x4eaea5['id']}}})[_0xb0a7('0x10')](function(_0x4a9560){_0x545a23=_0x4a9560;return util['getLicense']();})[_0xb0a7('0x10')](function(_0x28455c){if(_0x28455c&&_0x28455c['agents']&&_0x545a23>=_0x28455c['agents']){throw Error(_0xb0a7('0x11'));}_0x1402b5(_0x4eaea5);})[_0xb0a7('0x12')](function(_0x319d1b){_0x25a063(_0x319d1b);});});};